Dan Sugalski <[EMAIL PROTECTED]> wrote: > On Mon, 18 Aug 2003, Leopold Toetsch wrote:
>> Or coroutines shouldn't swap the control stack - I don't know. > They should, sort of. > Coroutines are a pain, but what they have to do is keep track of both the > top *and* bottom of their saved stacks. When a coroutine with active state > is invoked, it needs to take the parent pointers in the bottom stack > frames and make them point to the tops of the stacks that are in place > when the coroutine is invoked. (And when the coroutine exits saving state > those parent pointers need to be NULLed out so we don't hold on to stack > frames unneccesarily) This way the exception handlers and whatnot will be > properly in place when a coroutine is invoked. I see. What about the other stacks` I presume that continuations and coroutines don't need a copy of the user stack - a new one would do it (albeit it could be cheaper, to place the COWed copy in the context). What about the pad stack? Do coroutines have closure semantics? The current implementations puts the caller's pad in place. > Dan leo