std.reflection prototype

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 17 02:30:04 PDT 2015


On 2015-04-17 01:25, bitwise wrote:

> Ok, that sounds right. D has no multiple or virtual inheritance, so I
> guess things should be fine. C# is the same way(single inheritance,
> interfaces) which is likely designed to avoid these kinds of issues.
>
> I would be modifying the offTi() property though, not getMembers().
> getMembers() actually works right now, although it's kinda useless.
> Basically, if you put any function named "getMembers" at module scope,
> the address of that function can be retrieved using
> ModuleInfo.xgetMembers().

We need a "getMembers" on ClassInfo. Because "typeid" will resolve the 
dynamic type. The problem is this code:

class Bar {}
class Foo : Bar {}

void main ()
{
     Bar a = new Foo;
     writeln(typeid(a));
}

Compile time reflection cannot be used to get the members in this case.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list