CTFE - compiling other languages inside D

Adam D. Ruppe destructionator at gmail.com
Wed Aug 10 10:32:48 PDT 2011


Marco Leise wrote:
> An unlikely example would be a C compiler within CTFE that takes a
> string of C source code and turns it into a D mixin. Is that
> possible?

It'd be a fair amount of work, but it should be possible.

It's tempting to try to implement that as an alternative to D
bindings modules.

mixin include_C ( import("stdio.h") );


Turning Javascript into D is probably harder yet... but I still
think it could be done. tbh though, I think you'd be better off
using a javascript interpreter and duplicating a little bit of
effort to optimize stuff.

So you write it in javascript, then use a javascript engine in
your distributable app. Functions that are cpu intensive are then
rewritten in D so the script can call them and get better speed
out of it.


More information about the Digitalmars-d mailing list