Hacker News new | ask | show | jobs
by mehrdadn 2866 days ago
What do you mean what happens to them? Wouldn't they just be kept alive with the same semantics as how a variable used in a nested function is kept alive? Or is there more that I'm not aware of? If that's all there is to it, the semantics should be second nature if you've done Java, Python, or any other GC'd language, right?
1 comments

That’s one option. But the unfortunate conclusion of that choice is that continuations leak a lot of memory. One shot continuations are better, since it frees up the variable references.
I don't see how this is different from lambdas in general, in JS/Python/etc... wouldn't it only be held as long as the variables are alive? If you use the callback only once then they should be eligible to be freed after being used once.
http://okmij.org/ftp/continuations/against-callcc.html is pretty informative. It was kind of eye opening to see just how many corner cases there are when dealing with continuations.

(See the section “memory leaks”.)

Thanks for the link! Unfortunately I don't understand what it's saying the issue is... would you have a simple example to illustrate? It's been years since I did Scheme, I've never actually needed to use call/cc in a program, and I'm not advanced enough in Scheme to have seen shift/reset (as with call/c, their documentation is not quite clear). :\
I could, but not at 3 AM. :) I'll try to remember tomorrow.