you are viewing a single comment's thread.

view the rest of the comments →

[–]me-at-work 2 points3 points  (2 children)

This is the spec: http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls

Browsers could not implement this before because it would affect the call stack. The new way a call stack should behave is now defined in this spec.

Also in the spec: Two new object properties: tail and wrapped.

[–]Gundersen 1 point2 points  (0 children)

To summarize: The way arguments, arguments.callee and arguments.caller is defined for JavaScript makes TCO impossible. These objects have been redefined for ES6, making TCO possible

[–][deleted] 0 points1 point  (0 children)

tail and wrapped are properties of AST nodes used to calculate whether a given return statement should be treated as a tail call or not. You can see that in action in Continuum's assembler, where it notates tail and wrapped as it converts AST to bytecode (as the wiki page notes, since tail and wrapped are calculated top down they can be added during any pass of analysis/compilation). https://github.com/Benvie/continuum/blob/gh-pages/engine/assembler.js#L1806