3/23

IBM Developer 日本語版 : 大変申し訳ありません。このページは無効です。

型に短縮名を定義するための「typedef」機能が用意されていないため、開発者によっては「溺れる者がつかむ藁」としてエクステンションに頼ろうとし、望ましくない結果に終わっているようです。

確かにジェネリクスを使うとタイプ量が増えますが、優れたIDEやエディタがあれば解決する気が。また、C#の場合だと、

using System;
using System.Collections.Generic;
using StringList = System.Collections.Generic.List<string>;

class Program {

    static void PrintList (StringList sl) {
        foreach (string s in sl)
            Console.WriteLine (s);
    }

    static void Main () {
        StringList sl = new StringList ();
        List<string> ls = new List<string> ();

        sl.Add ("Hello");
        ls.Add ("World");

        PrintList (sl);
        PrintList (ls);
    }
}

とかも出来ますし、継承して云々はやらないなぁ。