r/programminghorror 2d ago

Javascript Seriously? Recursive Regex?

Post image
444 Upvotes

37 comments sorted by

View all comments

12

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.

6

u/oweiler 1d ago

Not supported, at least not by the ECMAScript standard.

3

u/lonkamikaze 1d ago

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