__traits so long and ugly, what about ::?

Ary Manzana ary at esperanto.org.ar
Wed Mar 30 12:28:27 PDT 2011


I think :: is not used in the language.

In a recent article about D I saw:

mixin(__traits(identifier, T) ~ " " ~
       to!string(tolower(__traits(identifier, T)[0])) ~
       __traits(identifier, T)[1..$] ~ ";");

What if foo::bar were an alias for __traits(foo, bar) ?

The code would look like this:

mixin(T::identifier ~ " " ~
       to!string(tolower(T::identifier[0])) ~
       T::identifier[1..$] ~ ";");

What do you think?

Another uses:

__traits(int, isArithmetic) ==> int::isArithmetic
__traits(C, isAbstractClass) ==> C::isAbstractClass

__traits(hasMember, S, "m") ==> S::hasMember("m")

Well, you get the idea...

:: might be applied to other compile time uses, but I just came up with 
this...


More information about the Digitalmars-d mailing list