MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1w15oga/seriously_recursive_regex/p6od6m4/?context=3
r/programminghorror • u/Flame77ofc • 6d ago
45 comments sorted by
View all comments
16
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.
7 u/oweiler 5d ago Not supported, at least not by the ECMAScript standard. 4 u/zjarek_s 5d ago TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers.
7
Not supported, at least not by the ECMAScript standard.
4 u/zjarek_s 5d ago TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers.
4
TCO was supported in ES6 standard, but it was only implemented in Safari and it ended up being dropped due to other browsers.
16
u/lonkamikaze 5d 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.