4 ms·
Exactly! As I understand it, the moment js gets nice things like tail calls or concurrency, with very little work ghcjs can too! I'm really really excited.
by carterschonwald 13y ago
Exactly! As I understand it, the moment js gets nice things like tail calls or concurrency, with very little work ghcjs can too! I'm really really excited.
- yoklov 13y agoUnfortunately, tail calls can't be implemented without breaking JS semantics. See: http://code.google.com/p/v8/issues/detail?id=457 http://code.google.com/p/v8/issues/detail?id=457 .
- carterschonwald 13y agoWell then I dream of a day when an ecmascript revision makes the breaking changes needed to fix this. Or some sort of clever hack works around that constraint
- luite 13y agoThe change is proposed for ECMAScript 6: http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_c... GHCJS currently uses a trampoline, but all calls are in tail position, so when this gets implemented we can easily generate code that uses native JS tail calls. Like GHC, GHCJS uses its own stack for non-tail calls.
- carterschonwald 13y agoI think native code GHC has its stack in the standard location, though it manages it explicitly (as most native code languages do). (I'll double check the ghc source later to make sure i'm quibbling correctly)
- ethzero 13y agoYou don't need tail calls in JavaScript in order have them in a language that compiles to JS. The tail call can be compiled as a while loop. This is what Scala does on the JVM (and presumably what Scala.js does as well).
- amalcon 13y agoThis only works with calls that can be resolved at compile time (unless you mean a trampoline). That happens to be most of the common use, which is great, but it's not perfect. Trampolines still work, albeit with a pretty substantial perf penalty.
- colanderman 13y agoNo. Automatic tail call elimination can't be implemented without breaking JS semantics. Manual tail calls can perfectly well be implemented without breaking anything.
- chongli 13y agoYeah, just add goto!
- colanderman 13y agoYes, add goto. If JS is going to be the "assembly language of the web", it needs a general branch construct or it will suck.
- yoklov 13y agoOf course! The parent mentioned JS getting them however, which is, as I mentioned, impossible.
- deleted 13y ago[deleted]