News for hackers. Stuff that matters.
Re:GHCJS - Haskell in the Browser by yoklov on Wednesday June 26, 2013 @12:43PM (#5947174)
Unfortunately, tail calls can't be implemented without breaking JS semantics. See: http://code.google.com/p/v8/issues/detail?id=457 .
Re:GHCJS - Haskell in the Browser by ethzero on Wednesday June 26, 2013 @02:13PM (#5947830)
You 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).
Re:GHCJS - Haskell in the Browser by amalcon on Wednesday June 26, 2013 @02:51PM (#5948147)
This 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.

Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @04:02PM (#5948616)
No. Automatic tail call elimination can't be implemented without breaking JS semantics.

Manual tail calls can perfectly well be implemented without breaking anything.

Re:GHCJS - Haskell in the Browser by yoklov on Wednesday June 26, 2013 @10:49PM (#5950469)
Of course! The parent mentioned JS getting them however, which is, as I mentioned, impossible.
Re:GHCJS - Haskell in the Browser by chongli on Wednesday June 26, 2013 @05:08PM (#5949066)
Yeah, just add goto!
Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @10:13PM (#5950350)
Yes, add goto. If JS is going to be the "assembly language of the web", it needs a general branch construct or it will suck.
Re:GHCJS - Haskell in the Browser by carterschonwald on Wednesday June 26, 2013 @01:56PM (#5947700)
Well 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
Re:GHCJS - Haskell in the Browser by luite on Wednesday June 26, 2013 @03:06PM (#5948245)
The change is proposed for ECMAScript 6: 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.

Re:GHCJS - Haskell in the Browser by carterschonwald on Wednesday June 26, 2013 @08:02PM (#5949900)
I 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)