7 ms·
> 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 "t
by masklinn 16y 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.
- silentbicycle 16y agoCPS is about much more than just callbacks, though.