News for hackers. Stuff that matters.
Re:SICP Goodness – Why you don't need looping constructs by bjoli on Friday June 29, 2018 @05:56AM (#17423530)
I would say that schemes looping constructs are too limited for comfortable use, but that tail call elimination makes implementing your own constructs very easy. I have reimplemented racket's for loops for guile using named let loops [0] which was not only pretty easy, but it was also easily understood and optimised by the guile compiler. The end result is as fast as a hand rolled named let for almost all cases (I still haven't found one where it is measurably slower, but I have only tested it in the repl where the compiler can make lots of assumptions)

For that reason alone I think tail call elimination is a must, especially in today's transpiling world.

[0]: https://bitbucket.org/bjoli/guile-for-loops

Re:SICP Goodness – Why you don't need looping constructs by soegaard on Saturday June 30, 2018 @03:30PM (#17432346)
"For that reason alone I think tail call elimination is a must, especially in today's transpiling world."

This is an important insight.

I feel the JavaScript implementors are dragging their on getting tail call elimination widely supported.

Re:SICP Goodness – Why you don't need looping constructs by bjoli on Sunday July 01, 2018 @04:21AM (#17434663)
I have re-implemented rackets for loops using named let in a way that allows me to almost reach feature parity in a weekend [0]. I could implement python's list comprehensions the same way without much fuss.

I can't imagine having to do the same using an already existing looping construct with it's own edge cases and subtle semantics.

[0]: I didn't think about post-guards when I started, and adding them now would mean having to do some restructuring of the quite hairy emitting macro, which I won't do since I don't see the use case for post guards for anything else than making in-value a bit more elegant

Re:SICP Goodness – Why you don't need looping constructs by kccqzy on Friday June 29, 2018 @06:45AM (#17423707)
ES6 used to mandate TCE but it was removed. No browser other than Safari implements TCE for JavaScript. Apparently the main reason is an inaccurate stack trace on exception.
Re:SICP Goodness – Why you don't need looping constructs by hajile on Friday June 29, 2018 @10:20AM (#17424653)
The latest spec still talks about tail call optimization. The big objection was to replace implicit tail calls with a syntax to specify functions that might tail call.

With TCO being part of the spec and the potential replacement spec killed off, browsers really need to start getting with the program.

JavascriptCore (safari), Node v6, duktape, jerryscript, XS6, etc all have proper tail calls. It breaks the community to not implement them. It's not a standard if its not standard.

Re:SICP Goodness – Why you don't need looping constructs by soegaard on Saturday June 30, 2018 @03:36PM (#17432374)
Explicit or implicit doesn't matter for compiling to JavaScript. Explicit tail calls are much better that no tail call support at all.
Re:SICP Goodness – Why you don't need looping constructs by hajile on Sunday July 01, 2018 @05:03PM (#17437570)
I agree, but the companies behind explicit calls dropped it, but are refusing to implement the current spec too. Their stupid politics endanger the js ecosystem.
Re:SICP Goodness – Why you don't need looping constructs by bjoli on Friday June 29, 2018 @08:45AM (#17424160)
I can understand that, but it is a shame they didn't chose to do so for self-recursing functions. That would at least tell you the stack trace up until that point.
Re:SICP Goodness – Why you don't need looping constructs by soegaard on Saturday June 30, 2018 @03:34PM (#17432369)
An often over-looked point: If you use tail calls to implement a loop, you aren't really interested in seeing the stack trace. Compare with a standard for-loop: you aren't interested in seeing all states of the for-loop in a stack trace.