|
|
|
|
|
by nix
5701 days ago
|
|
What the author is missing: tail recursion in constant space is an implicit requirement for practical use of CPS transformations. In fact this is probably the single biggest reason for wanting efficient tail calls in a language. ECMA doesn't require efficient tail recursion. Caveat programmer. |
|
If you're going to do real CPS programming in JavaScript, you'll want to use a trampoline or a timer mechanism to reset the stack.
But, in most cases, you do a little computation and then block waiting for an event.
When the continuation gets invoked by the event-handling loop, the stack is reset.