News for hackers. Stuff that matters.
Re:By example: Continuation-passing style in JavaScript by mattmight on Tuesday November 09, 2010 @01:39PM (#1887432)
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.

Re:By example: Continuation-passing style in JavaScript by nix on Tuesday November 09, 2010 @02:34PM (#1887624)
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.