Newbie initial comments on D language - RTTI and run-time reflection

Christopher Wright dhasenan at gmail.com
Mon Jan 28 19:34:11 PST 2008


Edward Diener wrote:
> Xinok wrote:
>> Edward Diener wrote:
>>> I have searched through the pdf documentation bit did not find a full
>>> explanation of RTTI facilities in D. The reason I ask about this is that
>>> it appears there is a 3rd party reflection facility but I do not see the
>>> documentation in D that explains if and how reflection works in D. Does
>>> it exist in D ? Is there documentation for it ?
>>>
>> D 2.0 is an experimental branch which supports compile time 
>> reflection. It's documented here:
>> http://digitalmars.com/d/2.0/traits.html
> 
> That is compile-time reflection, which is useful for creating code but 
> not for instantiating objects at run-time and finding out about them. It 
> is also very limiting in the form presented as one can not instantiate 
> objects in the compile time constructs based on the information 
> returned, but just react in a way to the information found. I am not 
> putting down the effort as it more than duplicates and is more effective 
> than the Boost traits library, since it is based on compiler knowledge.

Also, you can use the classinfo for a type to create new instances of 
that type, provided that type has a default constructor (one that can be 
called with no arguments). That doesn't let you do a whole lot, I 
realize, but it's better than nothing.



More information about the Digitalmars-d mailing list