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

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Jan 28 18:29:34 PST 2008


"Edward Diener" <eddielee_no_spam_here at tropicsoft.com> wrote in message 
news:fnm1qm$1tiu$1 at digitalmars.com...
> 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.
>
> Is there any run-time reflection in D ? If not I would like to make a 
> strong argument for it on this NG and then let others comment on it or at 
> least have Walter see it. I realize implementing run-time reflection in 
> any language is exceedingly difficult, but my argument would make a case 
> for its importance in D if it could be done.

There is flectioned (http://flectioned.kuehne.cn/), likely the library you 
mentioned.  The D compiler by default inserts some RTTI information, but 
it's not complete by any means.

The nice thing about compile-time reflection, though, is that you can use it 
to _create_ runtime reflection from within the language, rather than relying 
on a third-party tool to do so.  This offers the possibility of providing 
runtime reflection, which is a feature not everyone needs, as part of the 
standard library rather than as a built-in feature of the language. 





More information about the Digitalmars-d mailing list