Is __traits(derivedMembers) supposed to return mangled names?
Mike Hearn
mike at plan99.net
Fri Dec 5 13:13:40 PST 2008
The language spec is ambiguous, and DMD can apparently do either. This program prints
[a __T3TagS23_D11smartstruct4Test1aiVi1Z b __T3TagS24_D11smartstruct4Test1bAaVi2Z]
Note: this is a lame-ass hack around the lack of real metadata attributes in D2. It'd be nice if the real thing was supported.
import std.stdio;
template Tag(alias m, int i) {
mixin("const int tag_" ~ m.stringof ~ " = " ~ i.stringof ~ ";");
};
class Test {
int a; mixin Tag!(a, 1);
char[] b; mixin Tag!(b, 2);
};
int main(char[][] args) {
writefln(__traits(derivedMembers, Test));
return 0;
}
More information about the Digitalmars-d
mailing list