How To Re-evaluate A Block?

Andreas Raab raab at isgnw.CS.Uni-Magdeburg.De
Fri Nov 20 22:43:13 UTC 1998


Hi,

> What is the Squeak code I need to do before I send value to the protected
> block so that it can be re-evaluated?

It's not so easy since you're in a handler response. What you need is to
make sure that the retry response cleans up the caller stack up to the
#value message sent to the block so that the block is not recursively
executed. The way I did this in my little exception exercise was to use
something like: 

ExceptionHandler>>executeBlock: doBlock marker: marker

  retryBlock := [^marker].
  ^doBlock value.

retryBlock is the block that's been executed on Exception>>retry and the
#on:do: method was then actually done by the handler as some sort of

  [result := self executeBlock: doBlock marker: marker.
   result == marker] whileTrue.

The non-local return cleans up the stack here so you don't send #value
recursively to the block. It's a little tricky ;-)

  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list