Is there a good implementation of continuations in Java?
If so, what is the overhead like? The JVM wasn\'t designed with these sort of things in mind, right? So is t
If I understand this correctly, I suppose the obvious problem involves unwinding the stack with closure instances active. I suppose a language with lexical scope could in theory figure out that a child frame may create a closure instance, identify those intermediate frames that are referenced, and then it could malloc those frames instead of just pushing them on the stack.
For that matter, a compiler could malloc all frames or all parent frames of a closure referencing a non-globally-bound object.
I don't think the JVM restricts closures any more than a real machine, it's just that they fight the general stack paradigm and so they usually get punted.