compile time reflection to runtime reflection
Reiner Pope
some at address.com
Tue Jul 24 05:39:54 PDT 2007
BLS wrote:
> Warning: This idea is probabely not a strike of a genius.
>
> Simply said : Is Mr. Compiler able to produce a binary file which
> contains compile time reflection information ? In other words, a file
> which enable us to create classloader.d
>
> To make it very slick I suggest to introduce the keyword : rtf
> f.i.
> module Runtime;
> rtf class A
> output-> A.drr
>
> another idea is version(RTF)
>
> Well hopefully this idea is not a complete mess...
> Bjoern
>
I'm afraid I don't entirely understand where you put the rtf... as part
of the class's declaration?
But I think we already have enough to do it within D -- can't we use
__traits to find about the types, and generate structs at compile-time
using struct literals?
So you can make a template which builds up a Member[] array, and then a
Class[] array (supposing you could list all the classes in a module),
and then you just write (at global scope)
Class[] allClasses = GenerateRuntimeInfo!(my.module.name);
Now we can access it at runtime!
I started writing an example of how it would work, but I'm not too sure
of the details. But I still think that compile-time reflection is
enough: lifting information from compile-time to runtime is an easy
enough operation. The other way is not. :)
-- Reiner
More information about the Digitalmars-d
mailing list