Re:Optimization algorithms and functional JavaScript
by braythwayt on Wednesday July 22, 2015 @09:45PM
(#9933508)
Babel performs tail-recursion optimization.
It is, as far as I know, impossible to use trampolining to perform tail-call optimization outside of very limited special cases. You need to do either whole-program rewriting--which means rewriting both the original source and every library or module included--or you need control of the engine itself.
Whole-program rewriting is very impractical and additionally imposes the trampolining performance penalty on every function and method being invoked. It’s very much like implementing continuations by rewriting in continuation-passing style.
It is, as far as I know, impossible to use trampolining to perform tail-call optimization outside of very limited special cases. You need to do either whole-program rewriting--which means rewriting both the original source and every library or module included--or you need control of the engine itself.
Whole-program rewriting is very impractical and additionally imposes the trampolining performance penalty on every function and method being invoked. It’s very much like implementing continuations by rewriting in continuation-passing style.