Igor Stepanov's runtime reflection patch

Jacob Carlborg doob at me.com
Thu Jan 12 23:32:24 PST 2012


On 2012-01-13 00:50, Vladimir Panteleev wrote:
> Igor Stepanov has finished his runtime reflection patch, announced here
> a while ago. [1]
>
> DMD patch against commit c50eb5f (from December 31): http://j.mp/xdI0hb
> Druntime Github fork: https://github.com/IgorStepanov/druntime
>
> User classes can declare a getMembers method, which becomes available in
> the classinfo. The patch adds implicit generation of getMembers
> information for all classes and structures, which do not declare the
> method explicitly.
>
> Usage is simple: YourClass.classinfo.getMembers("field") returns a list
> of fields with that name (MemberInfo array). Use null to get all fields.
> This also works for modules and enumerations.
>
> The patch also adds linkage and argument information to function TypeInfo.
>
> An example of what would be possible with this patch: call arbitrary
> methods by name and a Variant array as parameters, and obtaining the
> result as a Variant.
>
> Igor has asked about the potential of this patch to be included into
> DMD. I imagine that the consensus would be that it should at least be
> enabled (or disabled) with a compiler switch, or attribute in the source
> code.
>
> [1]: http://j.mp/wZLCDb

Cool, but do we really want all these enums (Linkage, StorageClass and 
so on) at global scope?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list