Hacker News new | ask | show | jobs
by mattmight 5703 days ago
Good point. True.

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.

1 comments

When the continuation gets invoked by the event-handling loop, the stack is reset.

You're not compiling to C here: "the stack" may be a chain of heap-allocated activation records that are still live as far as GC is concerned. What you're describing might work but you'd want to test it to be sure.

EDIT: On reflection I agree that the setTimeout() approach should free the stack, however it's implemented.