Exception resignaling question
Avi Bryant
avi at beta4.com
Wed Jul 30 01:38:40 UTC 2003
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, 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
More information about the Squeak-dev
mailing list
|