DeRailed DSL (was Re: compile-time regex redux)

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sat Feb 10 09:57:20 PST 2007


Bill Baxter wrote:
> As for Andrei having Walter's ear.  I think Andrei has Walter's ear 
> mostly because Andrei is interested in the same kinds of things that 
> interest Walter.  I think everyone can tell by now that Walter pretty 
> much works on solving the problems that interest him.   Right now (and 
> pretty much ever since 'static if') the thing that seems to interest him 
> most is metaprogramming.  Hopefully some day he'll get back to being 
> interested in reflection.  But if he's really got the metaprogramming 
> bug, then that may not be until after he's got D's compile time 
> framework to a point where he feels it's "done".  But only Walter knows.

There is a deeper connection between runtime reflection and compile-time 
reflection than it might appear.

In the runtime reflection scenario, the compiler must generate, for each 
user-defined type, an amount of boilerplate code that allows symbolic 
inspection from the outside, and code execution from the outside with, 
say, untyped (or dynamically-typed) arguments.

The key point is that the code is *boilerplate* and as such its 
production can be confined to a code generation task, which would keep 
the compiler simple. The availability of compile-time introspection 
effectively enables implementation of run-time introspection in a library.

For example:

class Widget
{
   ... data ...
   ... methods ...
}

mixin Manifest!(Widget);

If compile-time introspection is available, the Manifest template can 
generate full-blown run-time introspection code for Widget, with stubs 
for dynamic invocation, the whole nine yards.

This is nicer than leaving the task to the compiler because it relieves 
the compiler writer from being the bottleneck.


Andrei




More information about the Digitalmars-d mailing list