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

Edward Diener eddielee_no_spam_here at tropicsoft.com
Tue Jan 29 19:30:09 PST 2008


Jarrett Billingsley wrote:
> "Edward Diener" <eddielee_no_spam_here at tropicsoft.com> wrote in message 
> news:fnmaec$2j4f$1 at digitalmars.com...
>> From the facilities mentioned at http://digitalmars.com/d/2.0/traits.html 
>> it is hard to imagine how one can create runtime reflection on unknown 
>> types at compile time.
> 
> By using compile-time reflection primitives to build up metadata structures 
> at compile time which are embedded in the app/library and which can then be 
> used to query information about modules, the types and functions in them, 
> etc.
> 
>> If it can indeed be done then it appears to be something that can not be 
>> done from the outside by a 3rd party tool since that tool would have to be 
>> able to be compiled and know about partcular types in advance in order to 
>> gather the data it needs.
> 
> No, it'd be done by using a tool that would parse D code into an AST, find 
> the declarations in it, and similarly to above, generate the same kind of 
> metadata.

Please, no one except a compiler itself parses source code anymore to 
build a reflection mechanism. If it is not in the compiler, asking a 3rd 
party mechanism to do it is really beyond the vast majority of 
programmers' ability. Sorry to be so negative but no other modern 
language of which I know, which has run-time reflection mechanisms, asks 
the programmer to go to such lengths. Look at .Net, Java, Python, Ruby, 
C++ Builder, or Delphi and tell me which ones ask the programmer to 
parse the language just to reflect on the type and their sub-components.



More information about the Digitalmars-d mailing list