typedef: what's it good for?

bearophile bearophileHUGS at lycos.com
Wed Nov 11 10:20:07 PST 2009


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.

If typedef gets removed from D, will the "typedef" keyword removed from the D language?

Bye,
bearophile



More information about the Digitalmars-d mailing list