Reasons to use D
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 12 13:03:06 PDT 2015
On Saturday, 12 September 2015 at 18:59:11 UTC, Ola Fosheim
Grøstad wrote:
> Array.slice create value copies, not reference views. I don't
> think there is a "slice" for Array. :-/
Right, that's why I said "kinda similarly"... the copy is really
important if you want to mutate it, but it is good enough for
viewing (tho poorly performing by comparsion).
> Compile GC-based D-JS -> JavaScript + TypeScript definitions.
That's basically what my D->JS thing did back in 2011.
> The problem is that you might need a little bit of Dependent
> Typing in order to provide types for the browser API. I.e.
> return type depending on parameter values? Not sure.
That doesn't actually happen very often, and when it does, you
can do a function overload like string foo(string s) { return s;}
vs int foo(int i) { return i; } and it works in D land pretty
well. Then use a pragma(mangle) to make both refer to the same
browser function.
That actually worked somewhat well in my dtojs but it was a mild
hassle too once function callbacks got more involved. You can
template them in D but then it bloats the generated JS for no
real reason since they all have identical dynamically typed code!
I suppose that is solvable too but i never got around to it and
just went back to writing normal javascript. (I write small JS
files anyway, it is an ok language for small scripts.)
More information about the Digitalmars-d
mailing list