Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Would tail call optimization help in this case? AFAIK JS's iteration methods aren't recursive.


Tail call optimization isn't just for recursive tail call optimization (though that is the most common scenario!).

It simply refers to 'unrolling' that function call, so a new function doesn't need to be added to the stack.

JS's iteration methods aren't currently recursive, at least in V8[0]. But that's probably due to lack of TCO!

0. https://github.com/v8/v8/blob/master/src/array.js#L1378




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: