On Sunday, 6 September 2015 at 20:22:23 UTC, Zoadian wrote:
obviously X has to be a compiletime js->d compiler.

Just a fun fact: my script.d's interpreter is itself CTFEable in modern dmd!


import arsd.script;

void main() {
        // script.d is similar to but not identical to javascript
        // so run that code in the interpreter and fetch a D
        // type right out all at compile time...
        enum a = interpret("var a = 5; a += 2; a;").get!int;
        pragma(msg, a);
}


$ dmd d ~/arsd/jsvar ~/arsd/script
7


jsvar.d and script.d can be found here:
https://github.com/adamdruppe/arsd

Reply via email to