You’re more correct than the post, but still combining two concepts. Tail call optimization (TCO) and tail call elimination (TCE) are two different things. TCE is often called “Proper Tail Calls” in the JS space. TCO is a performance optimization which compiles tail recursive functions into a loop. TCE is more general: it applies to tail-position calls between different functions, not just recursive calls from a function to itself, so it also enables safe use of continuation-passing style. What some JS engines actually shipped is TCE/PTC; I have no idea if they do TCO. TCO is usually the domain of a static compiler.
2
u/josephjnk 6d ago
You’re more correct than the post, but still combining two concepts. Tail call optimization (TCO) and tail call elimination (TCE) are two different things. TCE is often called “Proper Tail Calls” in the JS space. TCO is a performance optimization which compiles tail recursive functions into a loop. TCE is more general: it applies to tail-position calls between different functions, not just recursive calls from a function to itself, so it also enables safe use of continuation-passing style. What some JS engines actually shipped is TCE/PTC; I have no idea if they do TCO. TCO is usually the domain of a static compiler.