3 ms·
> The only thing that tail recursion changes is how much memory an operation will take. Tail recursion specifically changes whether a compiler can optimize awa
by foolmeonce 6y ago
> The only thing that tail recursion changes is how much memory an operation will take.
Tail recursion specifically changes whether a compiler can optimize away the stack, which means your out of memory will come from lack of memory for a stack. Whether the stack is allowed to use all memory is a decision beyond your control in a language that runs in a browser.
- slaymaker1907 6y agoYou can do this in the browser as well to a degree. Just use CPS plus a trampoline function (which is also a way to implement general continuations). Using promises also works since it is a restricted form of CPS.