Shouldn't __traits return Tuples?

Trass3r mrmocool at gmx.de
Mon Mar 30 06:06:09 PDT 2009


Shouldn't __traits return Tuples instead of arrays (esp. allMembers) to 
allow sophisticated compile time reflection?
Currently it seems impossible to do something along the lines of

foreach (member; __traits (allMembers, Class))
{
     foreach (overload; __traits (getVirtualFunctions, Class, member))
     {
         // do stuff
     }
}

Maybe it would be possible with Tuples using template recursion.



Also the following doesn't work with dmd, returns 0 for all members:

Base base = new Base;
auto members = __traits(allMembers, typeof(base));
foreach(m; members)
     writefln(base.classinfo.getMembers(m).length);



More information about the Digitalmars-d mailing list