introspection woes...

2011-06-13 Thread Lloyd Dupont
Trying to play with introspection. trying o, for a given object, to check its property by name. Experimenting with the function below. 1. it doesn't compile! mi.name() seems to be a problem? 2. match is always null! even though I pass the name of an existing property and / or field!

introspection woes (2)

2011-06-13 Thread Lloyd Dupont
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()); } } == However

Re: introspection woes (2)

2011-06-13 Thread Johannes Pfau
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()); } }

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
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

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:11, Lloyd Dupont wrote: 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

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
Thanks Robert! Mm.. can you (per chance!) share some code? I'm a newbie and compile time reflection is something which eludes me (so far...)! Robert Clipsham wrote in message news:it4vp1$1n5q$1...@digitalmars.com... Anyway of ... making the runtime update xgetMembers? My understanding

Re: introspection woes (2)

2011-06-13 Thread Robert Clipsham
On 13/06/2011 13:56, Lloyd Dupont wrote: Thanks Robert! Mm.. can you (per chance!) share some code? I'm a newbie and compile time reflection is something which eludes me (so far...)! See: http://www.digitalmars.com/d/2.0/traits.html class MyClass { void method1(){} void

Re: introspection woes (2)

2011-06-13 Thread Lloyd Dupont
Works a treat! Thanks for your detailed sample! :) Robert Clipsham wrote in message news:it5395$2028$1...@digitalmars.com... See: http://www.digitalmars.com/d/2.0/traits.html class MyClass { void method1(){} void method2(){} } import std.stdio; void main() { foreach