4 ms·
One annoying thing in JS is that you have to turn recursive functions into for-loops (you could argue this is a good thing as for loops might be easier to under
by z3t4 5y ago
One annoying thing in JS is that you have to turn recursive functions into for-loops (you could argue this is a good thing as for loops might be easier to understand then recursive functions). I thought the JavaScript callstack limit/error would go away in ES6 tail call optimization... But no JS engine seem to have implemented it!?
- iaml 5y agoSafari has tail call optimization I think.
- RobertKerans 5y agoPart of the spec, as sibling says implemented in Safari, was also implemented in a few specific other engine versions for testing then ripped out. Benefits didn't seem to outweigh the extra complexity: iirc the issue was to do with the semantics -- several engines wanted opt-in for proper tail call elimination (so, a syntax addition), rather than opt-out as per the spec (which seemed to involve a lot more work for what I'm guessing they saw as minimal benefit), so [again iirc] just sorta hit a stalemate.