5 ms·
I like this style of programming, but isn't there cause for concern in having such a deep call stack in JS?
by dinedal 15y ago
I like this style of programming, but isn't there cause for concern in having such a deep call stack in JS?
- gcr 15y agoYes. V8 and other JS compilers optimize tail calls, but it's not guaranteed by the standard. (i think IE doesn't, for example)
- mhansen 15y agoI'm not sure where you got this idea. V8 does not optimize tail calls. It's easy to see this in the Chrome console, I just entered this now: var a = function(x) { if (x == 0) return 'done'; return a(x-1); }; a(100000); RangeError: Maximum call stack size exceeded http://code.google.com/p/v8/issues/detail?id=457 http://code.google.com/p/v8/issues/detail?id=457
- gcr 15y agoWait, seriously? I didn't know that. Thanks for the link! Guess it's time for me to stop relying on that behavior...
- eru 15y agoYou could probably put a trampoline around it.