typedef: what's it good for?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Nov 11 10:59:35 PST 2009
bearophile wrote:
> Andrei Alexandrescu:
>
>> Walter's and my interim conclusion last night was that fixing typedef
>> would be difficult, and that the usefulness of typedef is too little for
>> its complexity. It may be a good idea to just remove it from the
>> language.
>
> An usage of typedef:
> alias int[5][20] TyMat;
> typedef Mat TyMatA;
> typedef Mat TyMatB;
>
> Now a function can take both a TyMatA and TyMatB matrix, and the type system helps you to not confuse one for the other when you pass them around.
You may want to test what happens when you mix TyMatA and TyMatB in some
operation.
> If typedef gets removed from D, will the "typedef" keyword removed from the D language?
I would think so.
Andrei
More information about the Digitalmars-d
mailing list