Dan Sugalski <[EMAIL PROTECTED]> writes: > At 8:46 AM +0100 3/23/04, Leopold Toetsch wrote: >>Piers Cawley <[EMAIL PROTECTED]> wrote: >>> Dan Sugalski <[EMAIL PROTECTED]> writes: >> >>>>> And what control stack? The continuation chain is the control >>>>> stack, surely? >>>> >>>> Nope. There's the exception handlers, at the very least. >> >>> Just add a field to the continuation structure "NextExceptionHandler" >>> which points to the continuation of the next exception handler in the >>> chain. >> >>What about C code that either installs exception handlers or throws >>exceptions?
C code that installs exception handlers is (admittedly) tricky, but C code throwing an exception seems reasonably straightforward. Wrap the C call in a basic exception handler that catches the C exception and rethrows to the current continuation's exception continuation. > Or multiple nested exception handlers, Invoke the exception continuation, which restores the appropriate current contination (and associated exception continuation) rethrow the exception by invoking the new current exception continuation, which restores a new current continuation (and associated exception continuation). Rinse. Repeat. > or serial exception handlers in a block... Installing an exception handler sets the current exception handler, removing it unsets it, then you install a new one. Any function calls will get appropriate exception continuations depending on the currently set exception handler. > And then there's the fun with exception handlers and > coroutines. > > It's a stack, like it or not. So what happens when you invoke a continuation that jumps deep within a functional call chain with a couple of exception handlers? What happens when you do it again? ie: Is the control stack properly garbage collected?