Exception resignaling question

Stephen Pair stephen at pairhome.net
Tue Jul 29 18:59:09 UTC 2003


Andreas Raab wrote:

>>PS: Andreas: just sending 'signal' again does not work in my 
>>3.5 image, but works ok in 3.6. So everything is fine... Thanks.
>>    
>>
>
>Quite interesting. I'm sure ANSI must be saying something about these
>issues, e.g., #resignalAs: from outside the handler block as well as #signal
>once the exception has been signaled and handled. I really wonder what the
>expected behavior is...
>
>Cheers,
>  - Andreas
>

This would imply that you would want to be able to #resume an exception 
outside the handler block as well.  This is actually not an unreasonable 
thing to either allow or to implement...but it requires two things:

1) we stop trying to fit contexts into a rigid stack model, and instead 
think of them as belonging to a tree (with all contexts ultimately 
pointing back to a single root context in the system)...the intial 
context of a forked process would point back to the context that forked 
it (we would need to maintain a separate sender chain for the purposes 
of the interpreter's call return mechanism...we might have a 
senderContext, and a  responseContext...when returning, then  
interpreter would follow (and nil out) the response chain, while the 
sender chain is preserved).  On a fork, we might want to capture the 
current state of the instruction pointers and maybe the temporaries such 
that we can recreate the call chain all the way back to the root context 
in the debugger.  The inital context in a forked process would have its 
senderContext set to the caller, but the responseContext would be nil, 
indicating to the interpreter that the process should die once it 
returns from that context.  The root context would probably be a loop on 
an event stream.  A nice property of this tree model is that exception 
handlers would propogate across forked processes (because we would be 
following the sender chain all the way to the root context to find a 
handler).

2) we start thinking of an exception as being a kind of continuation 
that basically takes a snaphot of the stack and allows you to resume as 
many times as you like (providing that the exception is resumable in the 
first place)

We could very easily allow #resume to occur outside of a handler, and we 
could even allow an exception to be resumed multiple times!  With the 
tree model, the exception handling code becomes much, much simpler.

- Stephen



More information about the Squeak-dev mailing list