Idea: Run Time Compilation

Pragma ericanderton at yahoo.removeme.com
Fri Mar 9 13:32:11 PST 2007


Craig Black wrote:
> Since Walter is in the habit of adding super advanced features to D, I 
> thought it possible that this one might eventually make it in.  As always, 
> please let me know if I'm way off base.
> 
> What if we could invoke the compiler from an application at run time and 
> generate a function that would be instantiated on the heap?  The function 
> would be defined by a text string and would be invoked via a function 
> pointer or delegate.  This would allow a script-like capability with 
> fully-optimized performance provided by the D compiler.  I think the D 
> compiler would be ideal for this since it is so fast.  Since the method 
> would be allocated on the heap dynamically, it could also be removed when it 
> is done being used.
> 
> Thoughts?

Plenty.  I've tried my best to approach this kind of functionality for some time in library space.  However I have my 
doubts as to having this included in D proper - since D is so minimal at it's core, it becomes very much a library 
support problem.

(I'll leave the DSP/DDL/Flectioned discussion for another thread).

I can say from experience that doing this from within library space is perfectly feasable, and yields some great 
results, at the cost of additional memory at runtime and a small (one-time per module) delay for compilation and runtime 
binding.  I would have sooner considered drafting a runtime compiler if DMD wasn't so fast.

-- 
- EricAnderton at yahoo



More information about the Digitalmars-d mailing list