[POLL] Process>>terminate
Paolo Bonzini
bonzini at gnu.org
Tue Oct 16 05:16:01 UTC 2007
Igor Stasenko wrote:
> Also note, that because we have only the 'soft' terminate, this leads
> to appearance of some evil code like:
>
> block := [ [ true] whileTrue: [ ... ] ].
where?
> or even #addOnTerminate: block , which will add a block to a list of
> blocks which will be evaluated when process is terminating.
>
> Also, i not agree that terminate must be connected with exceptions.
Also in Java termination trigger an exception. Here, the point is that
abrupt termination of a process is a nasty thing, something that's going
to cause bugs unless you take special measures (witness the mess that is
done in Delay to avoid half-updating the data structures), and the
process must know about it! A hard termination must only be used as a
last measure, really.
If you use these termination blocks heavily, you will soon want to
remove them. And sooner or later you realize that the best way to
remove them is to store their information somewhere on the context chain
which is where #ensure: and exceptions put it.
The fact that process execution flow *can* be controlled by an exception
is also hinted by a method such as Process>>#signalException:, which
will even wake up a process temporarily for the sake of signalling that
exception. (Other Smalltalks, such as VA and GNU, have a more generic
#queueInterrupt: method that takes a block, but Squeak's solution is
also very elegant).
Paolo
More information about the Squeak-dev
mailing list
|