On Sun, Jan 6, 2013 at 7:46 PM, d coder <dlang.co...@gmail.com> wrote:
> > You can use a string mixin: >> >> class Foo >> { >> int a; >> @(3) private int b; >> } >> >> void main() >> { >> writeln(mixin("__traits(getAttributes, " ~ Foo.tupleof[1].stringof ~ >> ")")); // -> 3 >> } >> >> >> > > Hmm.... > > This works only when main is in the same file (and therefor module) as Foo. > > Yes, but the OP question was to get the attributes in a generic way. The interesting part is the mixin, the rest is just scaffolding to print a result. If Jacob adopts this solution, he can insert these mixins where he needs them.