[Squeak-e] Are Handlers Dynamically Scoped? (was: Comments on Lex's "Object as Capabilities in Squeak")

cg at cdegroot.com cg at cdegroot.com
Mon Feb 3 11:32:02 CET 2003


Mark S. Miller <squeak-e at lists.squeakfoundation.org> said:
>Could you please explain this example in enough detail that I could try 
>rewriting it using only lexical scoping?
>
The idea is along the lines of:

someMethodInTheUserInterface
  [some operation, goes very deep]
     on: FloppyNotPresentError
     do: [:ex |
	Dialog ask: 'Please insert floppy'.
	ex restart]

The idea is that 'some operation' may contain side effects, which makes
the alternative idom employing a loop and a retry of the whole operation
unattractive. You cannot put the Dialog box in the, say, floppy
formatting routine, because the floppy formatting routine shouldn't know
about the UI. And splitting:

do bit with side effects.
while ...
   repeated loop containing the exception handling

is often not good either, because it is a single logical operation
(say 'dumpLogsToFloppy', a domain-level method that gathers logfiles,
zips them, formats a floppy, and dumps them to it) that the UI doesn't
need to know about to such an extent that it can split off the side
effects in order to have the failure-prone bit in a separate
non-restartable exception context.

-- 
Cees de Groot               http://www.cdegroot.com     <cg at cdegroot.com>
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD  1986 F303 937F E098 9E8B
Cogito ergo evigilo


More information about the Squeak-e mailing list