D to Javascript converter (a hacked up dmd)

Adam D. Ruppe destructionator at gmail.com
Tue Feb 28 11:56:33 PST 2012


On Tuesday, 28 February 2012 at 19:27:57 UTC, Piotr Szturmaj 
wrote:
> Can it compile a function to native code and JS simultaneously? 
> I want to execute the same code on both client and server side.

You'd have to run dmd twice because it exits before getting
to the backend when doing js.

But you can run the same code:

dmd -md file.d # outputs file.js
dmd file.d # outputs file.exe


You might need versions or something for library support,
but that's just because I haven't ported much over yet.


I just now tried:

import std.algorithm;
auto range = sort!"a < b"(["b", "a"]);
window.alert(range.front);

.. and it produced 44 KB of Javascript
code that *almost* worked.

Looks like I have to fix the dollar expression,
but otherwise, almost usable.


More information about the Digitalmars-d-announce mailing list