introspection woes (2)

Lloyd Dupont ld-REMOVE at galador.net
Mon Jun 13 05:11:45 PDT 2011


Interesting... I think I understand...
Thanks! :)

However an other problem arise with getMembers() it always returns null!
Looking at the code it seems (from my beginner's perspective) that 
getMembers() rely on the member field (function) xgetMembers which is always 
null, as far as I can tell (didn't see any assignment...)

Anyway of ... making the runtime update xgetMembers?



"Johannes Pfau"  wrote in message 
news:20110613140030.70c8d27b at jpf-Satellite-A100...

Lloyd Dupont wrote:
>trying to learn introspection, I have this simple test method:
>
>===================
>static void dumpelement(Object o)
>{
>    if (!o)
>        return;
>
>    auto ci = o.classinfo;
>    foreach(mi ; ci.getMembers(null))
>    {
>        writefln("%s . %s", ci.name, mi.name());
>    }
>}
>==================
Looks like getMembers() returns 'const MemberInfo' but name() is not
declared as const. That's likely a bug in druntime, but as a workaround
you can try this:

==================
writefln("%s . %s", ci.name, (cast(MemberInfo)mi).name());
==================



More information about the Digitalmars-d-learn mailing list