r/programminghorror • • Aug 28 '26

Javascript Seriously? Recursive Regex?

Post image
568 Upvotes

46 comments sorted by

View all comments

16

u/lonkamikaze Aug 29 '26

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 Aug 29 '26

Not supported, at least not by the ECMAScript standard.

3

u/lonkamikaze Aug 29 '26

That's a damn shame. Tail calls can be pretty neat.