ES6 Tail Call Optimization
ES6 Tail Call Optimization has landed in WebKit:
Could you elucidate this quote: "We are still evaluating this technology. There may be significant spec stabilization, foundational work, or additional community input required before we can begin development."?
Regarding proper tail call elimination, the spec is stabilized, and foundational work is at least as old as the first Scheme compiler.
In order to be able to effectively compile languages with proper tail calls (e.g. Scheme) to Ecmascript, this is a must-have-feature. Furthermore, for an Ecmascript programmer, this allows for a continuation-passing program style without having to worry about stack overflows.
I've implemented proper tail calls in the Traceur transpiler. It is working but with a heavy loss of performance due to missing language support by the current Ecmascript engines.
I'd love TCO and have voted for it - it would be wise to see why others have not included it in their languages. There are threads out there about this for Python and Ruby and reasons why it was not included in the end.
Brian Mitchell commented
While it will likely be some time before widespread support can be counted upon, it's very important for some things that may wish to target JS. It would also be advantageous to find a clean way to detect proper call elimination compliance w/o trying to run the stack out as we see in this test: https://kangax.github.io/compat-table/es6/#proper_tail_calls_(tail_call_optimisation)_mutual_recursion.
Roy Tinker commented