Exception resignaling question

Stephen Pair stephen at pairhome.net
Wed Jul 30 17:37:12 UTC 2003


Avi Bryant wrote:

>On Tue, 29 Jul 2003, Stephen Pair wrote:
>
>  
>
>>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:
>>    
>>
>
><snip>
>
>I'm not sure the tree model is necessary,
>

No, certainly not necessary (since we've lived without it this long), 
but before an exception handling system existed for Squeak, I did one 
that worked off of a tree model and the code to handle the various 
intricacies of exception handling was vastly simpler.  Taking that idea 
further and linking up forked stacks (to make a tree) seems like it 
might be a an interesting avenue to explore.  After all, the tree is 
there, we just don't capture a good representation of it.  The is 
something comforting about knowing that all contexts would ultimately 
point back (through the sender chain) to a single root context in the 
system.

Regarding continuations as exceptions, I think you have it 
backwards...perhaps exceptions should follow the continuation 
pattern...one path leads to the debugger, while another sits there 
waiting for you to make a decision about what to do (and under common 
circumstances, the actual creation of the continuation could be 
optimized away).  But, reconciling the mechanisms is certainly a worthy 
endeavor I think.

Looking at the two examples, I do however prefer the #resume: method 
over #value:...I think most people would expect a call to #resume: would 
do funky things with control flow, whereas I don't think most people 
would expect that from #value: (I think most people would be expecting 
that call to return to the caller).

- Stephen

> but you raise an interesting
>question - would continuations seem more natural in Smalltalk if the
>interface to them was as re-resumable exceptions?
>
>For example, I posted an example something like this on c.l.s. a little
>bit ago:
>
>|x continuation|
>x := Continuation currentDo:
>      [:k |
>      continuation := k.
>      42].
>Transcript cr; show: x.
>x < 50 ifTrue: [continuation value: x + 1].
>
>This should print out the numbers 42 through 50.
>
>However, it could equally well look like this:
>
>|x exception|
>x := [ReResumableException signal]
>        on: ReResumableException
>        do: [:ex | exception := ex.  42].
>
>Transcript cr; show: x.
>x < 50 ifTrue: [exception resume: x + 1].
>
>I have a feeling that might be easier for most Smalltalkers to follow.
>Is it?
>
>Avi
>
>
>  
>


-- 
- Stephen
_________
Do you need:
  Web/Domain/Application Hosting?
  Mailing List Services?
  IMAP/POP3/Web Email Accounts?
  Instant Messaging Accounts hosted on your domain?

Email me for information.




More information about the Squeak-dev mailing list