DDMD and such.
Nick Sabalausky
a at a.a
Wed Sep 28 15:12:23 PDT 2011
"Gor Gyolchanyan" <gor.f.gyolchanyan at gmail.com> wrote in message
news:mailman.269.1317240309.26225.digitalmars-d at puremagic.com...
>I was thinking more of a run-time D interpreter as a library solution.
> One of D's features could be the ability to interpret itself at
> run-time as a script of some sort. Having a compiler as a library
> solution would further improve this by generating DLLs from given code
> programmatically and return symbols. This would be even better, then
> java's dynamic class loading.
>
I've actually started work on a way to do this that works by invoking a dmd
command line, running the result, and capturing the stdout output. I
actually got a very, very basic form of it working (all it can do, IIRC, is
perform some processing and then return an integer or a string). This
approach has a *very* high overhead cost, so you'd only want to use it for
things that are already computationally expenive anyway, but it's
technically viable:
The function:
http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/util/process.d#L49
Example usage:
auto x = eval!int(q{ return 42; });
assert(x == 42);
auto str = eval!(char[])(q{ return "Test string".dup; });
assert(str == "Test string");
The use of serialization could extend that to other types.
More information about the Digitalmars-d
mailing list