std.reflection prototype

bitwise via Digitalmars-d digitalmars-d at
Sun Mar 29 18:11:53 PDT 2015

I came across this post a while back and decided to implement it:$16rl$

My implementation:

The above conversation seemed to stop abruptly, so I went on to 
assume that no one chose to champion the task.

At the time, I looked around for other conversations or attempts 
at runtime reflection for D, but couldn't really find anything. I 
did find the ModuleInfo/reflection stuff in object.d, but it 
seemed like an effort that may have been abandoned. Also, the 
above conversation seemed to suggest it should be opt-in, which 
also made me wonder if the stuff in object.d was abandoned or for 
a different purpose.

Looking again today, someone seems to have been working on it a 
bit.. For example, MemberInfo_field and MemberInfo_function were 
empty last time I checked.

So what's the current state of things?
Is anybody working on it?

Although MemberInfo_field exists, it doesn't seem to be available 
from TypeInfo_Class... Is that the eventual goal?

Is there anything I can do to help get things moving?

Any comments on my implementation would be welcome as well.

main.d shows some general use cases, but basically, if the 
reflect(T) template is used on a class,
that class, and any child types will be reflected. Recursive 
reflection only propagates downward, or else it could leak 
sideways and unnecessarily reflect several modules.

Most of the reflection information is available at compile time. 
For example:

enum name = 
pragma(msg, name); // "variable" will be outputted.

To make a module available for runtime reflection, the following 
can be used:

At this point, the above example can be rewritten as:

string name = 

More information about the Digitalmars-d mailing list