recursion - Why do no javascript engines support tail call optimization? -


i learned tail call optimization in haskell. i've learned following posts not feature of javascript:

is there inherent javascript's design makes tail call optimization difficult? why main feature of language haskell, being discussed feature of javascript engines?

tail call optimisation supported in javascript. no browsers implement yet it's coming specification (es2015) finalized , environments will have implement it. transpilers babeljs translate new javascript old javascript support , can use today.

the translation babel makes pretty simple:

function tcome(x){     if(x === 0) return x;     return tcome(x-1) } 

is converted to:

function tcome(_x) {     var _again = true;      _function: while (_again) {         var x = _x;         _again = false;          if (x === 0) return x;         _x = x - 1;         _again = true;         continue _function;     } } 

that - while loop.

as why it's newly supported, there wasn't big need community sooner since it's imperative language loops vast majority of cases can write optimization (unlike in mls required, bergi pointed out).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -