Dealing with type information loss in Parameters Fields and Return type

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 17 16:08:44 PDT 2016


On Sunday, 17 April 2016 at 13:56:38 UTC, Jonathan M Davis wrote:
> Perhaps, but be aware that Walter Bright thinks that size_t 
> should stay as-is:
>
> http://forum.dlang.org/post/nevrsb$2ge1$1@digitalmars.com
>
> Maybe some sort of general change to how aliases work would be 
> acceptable and would give you what you want. I don't know. But 
> he's against special casing stuff like size_t.
>
> - Jonathan M Davis

I was just going to make a __traits that returns a tuple of 
string lf the types as seen by the parser (i.e. "size_t"). While 
size_t and ptrdiff_t are the most common case they are not 
special. e.g.
version = B;
version(B)
{
     struct b{}
     alias A = b*;
}
version(C)
{
     struct c{}
     alias A = c*;
}
void foo(A a){}
writeln(Parameters!foo);//prints b*
writeln(__traits(whatevericallit,foo);// prints A


More information about the Digitalmars-d-learn mailing list