Can you do this in D?
David Nadlinger
see at klickverbot.at
Fri Jul 27 00:00:34 PDT 2012
On Thursday, 26 July 2012 at 12:17:23 UTC, Wes wrote:
>> In general, no. But you can get a list of all members in a
>> module or class scope. Just use __traits(allMembers, ...);
> The allMembers example was lacking fields. It only showed
> methods, so I wasn't really sure. The problem with it was that
> it returned strings. I suppose I can still use them in a mixin.
If you don't want to use mixins, you can also use
__traits(getMember, instance, name). mixin("instance." ~ name) is
shorter, though.
David
More information about the Digitalmars-d
mailing list