Hacker News new | ask | show | jobs
by masklinn 5704 days ago
> ECMA doesn't require efficient tail recursion. Caveat programmer.

You can always use setTimeout to call your tail, which has the neat effect that your CPS "threads" become cooperatively multitasked and can progress alongside each other. Just replace "foo()" tail calls with "setTimeout(foo, 0)".

And the downside that you're nuking your stack every time, making debugging quite a bit harder.

1 comments

CPS is about much more than just callbacks, though.