Compiling D inside of a D program
Kelet
kelethunter at gmail.com
Sat Dec 21 02:00:09 PST 2013
On Saturday, 21 December 2013 at 08:55:04 UTC, Mineko wrote:
> This is a fairly basic question but I can't find any good
> answers, so I'm asking..
>
> Anyways, I want to be able to invoke the D compiler, whichever
> that might be from inside of a D program, so I can say, compile
> a D script on-the-fly in some game, it's just an idea though.
>
> To be even more to the point, how can I invoke the D compiler
> inside of a D program, also, do I need to bundle said D
> compiler with my program or does D have some compilation
> feature inside of an already compiled program (Which I doubt)?
Hi, I was also interested in this topic. My research suggests
that there is no easy or safe way to do this at the moment, as
thedeemon suggests. Although I think it's worth offering a
possible alternative: using a scripting language binding like
LuaD[1], DerelictLua[2], or pyd[3]. From here, you can expose
some functions/variables between them, and solve a lot of the
same problems.
That being said, I think it would be useful to have something
like JavaCompiler[4]. It's not an optimal solution, but combined
with a minimal compiler package it could help a lot.
As far as I know, you need to ask permission to distribute DMD
with your application, so it may be safer to include GDC or LDC
if you want to go this route. Or ask Walter, of course.
[1]: https://github.com/JakobOvrum/LuaD
[2]: https://github.com/DerelictOrg/DerelictLua
[3]: https://bitbucket.org/ariovistus/pyd
[4]:
http://docs.oracle.com/javase/7/docs/api/javax/tools/JavaCompiler.html
Regards,
Kelet
More information about the Digitalmars-d-learn
mailing list