Reflection Idea

Pragma ericanderton at yahoo.removeme.com
Thu Sep 14 15:32:05 PDT 2006


Craig Black wrote:
> Since DDL provides run-time reflection, and is finally ready to use, I 
> thought it would be a good time to share my idea to improve performance when 
> accessing metadata.

Technically DDL does, although I'm hesitant to call it that since it 
doesn't have all the typical reflection bells-and-whistles yet.

> 
> If we have an instance of a class and we want to it's metadata via a 
> reflection database, we should be able to query the reflection database 
> using a hash table lookup on the name of the class.
> 
> However, we could get the metadata more quickly if it was available via the 
> TypeInfo class.  This could be made possible very easily if the TypeInfo 
> class contained a reference to an IReflection interface.  This reference 
> could be set by the reflection database at program startup.  This would 
> provide a direct link to meta data for each class, and would make reflection 
> a first class citizen in D.

The only reason why I'd consider full-on reflection for D a bad move is 
that it'll bloat program sizes considerably.  This is kind of contrary 
to D's goal as a systems programming language.  Taking into 
consideration the sheer size of your average .map file is a good 
indicator of just how bad things can get.

So I'd caution the addition of adding such a suite to D as something 
optional if at all possible.  Even something minimalisitc would work - 
like the inclusion of just a hashtable of all the program's symbols 
(metadata as Craig put it above) that is *optionally* compiled in.

Otherwise, we're stuck with .map/.situ support under DDL - i.e. using 
your .map file as a runtime dependency for the program.  While this 
works well, and is such a dead-simple way of addressing the problem, 
it's also easy to get out of sync IMO.

[PSA]

Craig, if you're at all interested in hammering out a reflection 
interface (for DDL?), the DDL Community wiki there is open for your, and 
everyone else's abuse.

http://www.dsource.org/projects/ddl/wiki/Community

I have some reflection concepts, and a few other ideas, outlined under 
the DevNotes section as well:

http://www.dsource.org/projects/ddl/wiki/DevNotes

Enjoy!

-- 
- EricAnderton at yahoo



More information about the Digitalmars-d mailing list