Runtime Reflection For Real - was D scripting (c++ integration)

pragma ericanderton at yahoo.com
Mon Oct 2 16:46:05 PDT 2006


J Duncan wrote:
 >
 > Yeah I think its completely feasible. In fact I think the dflect project
 > does something similar with the C++ front end. it generates reflection
 > data into a source module that gets compiled and linked into the final
 > binary. something like this is more than feasible, we just need to come
 > up with a good system. We need a good data representation of reflection
 > info plus an api to access it. we could just generate source code to
 > compile into a project - or even go all the way to produce an OMF binary
 > file.... In my mind just about everything we want to do is right in
 > front of us, we just have to choose a path. And I am not one that is
 > good at defining systems for a community to use, so I have mostly stuck
 > to my personal projects so far. My only prior experience at reflection
 > is openc++ and their compile time system, which in theory is way cooler
 > than in practice. Over the last year or so I have tried to instigate
 > interest in the D community for both compile-time and runtime
 > introspection systems. I dont have any experience with java reflection
 > so I was hoping more informed people than myself would come forward with
 > ideas and comments.
 >
 > as for compile-time reflection it is best handled by the compiler;
 > however we can do it outside the compiler by generating intermediate
 > source code; something I have been experimenting with but not sure its
 > really practical on a large project, and it causes debugging issues.
 >
 > Anyway i tend to ramble - all the pieces are there for basic runtime
 > reflection information; we just need a good system.


Well, not to sound too much like $YOUR_CRANKY_OLD_LISP_LOVING_CS_PROF 
but any lib is only as good as the use cases it supports, and the use 
cases it's target audience has a need for solving.

I like Java's and I like C#'s even more (it includes code *generation*), 
and they cover pretty much the same set of use cases.  I think D could 
easily emulate C#'s and with a little tweaking, come out about as 
useful.  Java has the upper hand in it's own little world, because this 
effort would be done without built-in language support, so some idioms 
can't be achieved.

So I'd like to propose a different tactic that has worked well for me in 
the past.  Rather than try to be Everything To Everyone(tm) I'd 
reccomend tackling a few common uses for reflection/introspection and 
design from that point forward:

- "Type-Blind" Serialization (generic serialization w/o templates)
- Generic Call Proxies (useful for RMI and other message-passing tasks)
- Signal-Slot (huge thread right here in the DNG on that)

I'm sure there are others that folks might come up with.

Anyway, you're probably already doing something like this, since you 
already zeroed in on the big one: IDE integration for real-time code 
browsing.  I propose the above cases, because they've come up around 
here before so you're likely to get at least a few souls who will take 
it for a spin once completed.



More information about the Digitalmars-d mailing list