D to Javascript converter (a hacked up dmd)

Adam D. Ruppe destructionator at gmail.com
Thu Mar 1 08:43:08 PST 2012


On Thursday, 1 March 2012 at 16:29:10 UTC, Robert Clipsham wrote:
> Perhaps it would be better to have a dedicated function for 
> that though.

eval() :)

I considered doing asm {} for javascript, but that'd be a
pretty invasive change to the compiler, so I decided against
it; I want to keep most the changes as simple as possible.

One possibility would be a special function, let's call it
static_eval, that takes a string but instead of being a
function call, simple pastes the string itself into the
js file.

But, I haven't really wanted it yet! All the functions I
want have been implementable in relatively plain D (with
the addition of the __js_keywords in some places), except
foreach on associative arrays.

I had to hardcode that function, since there's no way to
represent for(i in obj) on the low level.



For phobos btw, I haven't decided how to run with that yet.
My first thought was to implement my own version - test/std
shows this - that emulates the interface using native JS
functions where possible.

That will be hard to keep up to date, and causes conflicts
if you want to borrow a little from the real Phobos. So
eh, I don't know yet.


More information about the Digitalmars-d-announce mailing list