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;
}

Reply via email to