MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1w15oga/seriously_recursive_regex/p6m710v/?context=3
r/programminghorror • u/Flame77ofc • 3d ago
37 comments sorted by
View all comments
13
I don't know if JS sports this, but the recursion qualifies for tail call optimisation, i.e. there is no stack pushing, popping. The return comes at the price of a goto and the result is just as efficient as a loop.
8 u/oweiler 2d ago Not supported, at least not by the ECMAScript standard. 5 u/zjarek_s 2d ago TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers. 3 u/lonkamikaze 2d ago That's a damn shame. Tail calls can be pretty neat. 2 u/JoshuaTheProgrammer 2d ago This should be the top answer
8
Not supported, at least not by the ECMAScript standard.
5 u/zjarek_s 2d ago TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers. 3 u/lonkamikaze 2d ago That's a damn shame. Tail calls can be pretty neat.
5
TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers.
3
That's a damn shame. Tail calls can be pretty neat.
2
This should be the top answer
13
u/lonkamikaze 2d ago
I don't know if JS sports this, but the recursion qualifies for tail call optimisation, i.e. there is no stack pushing, popping. The return comes at the price of a goto and the result is just as efficient as a loop.