The State of Exceptions

R. A. Harmon harmonra at webname.com
Mon Oct 12 14:35:44 UTC 1998


At 10:01 PM 10/11/98 -0700, Tim Rowledge wrote:
>On Sun 11 Oct, David Farber wrote:
>
>> what exactly is the issue here with unwind support? i remember you asking
>> something along these lines a while back, but i don't remember replying.
>> that's probably because i didn't (don't) understand the issue here. when i
>> ported the exceptions code to squeak, i wasn't aware of any cases that it
>> didn't handle.
>Unwind support is needed to handle the case of a non-local return merrily
>skipping past your unwind protection block, leaving your files open,
>sockets flailing or other catastrophes imminent.
>A non-local return can jump from one context back up to another without
>passing Go, thereby causing untold trouble. The VM mod would scan up the
>stack from source to target, checking for marked contexts on the way; any
>marked context found woud be sent a suitable message, somewhat like
>#cannotReturn:. Indeed, somebody (Andreas?) mentioned the possibility of
>overloading the cannotReturn handling to provide unwind protection. Sounds
>plausible to me.
>
>IIRC, the VW code quite probably has examples of unwind code needing this
>facility provided somewhere in the class methods.

I implemented in Squeak all the ANSI exception protocol messages by hacking
up VSExceptions_8Augu1001pm.cs by Tim Jones (tim at thregecy.com 1997).  It
does not use the marked contexts mechanism.  The .doc file notes that

        "this package fails to catch returns from an ensured block, and the
        termination of the process. i plan to address these faults soon if
        someone else doesn't beat me to it."

This seemed to me to be a reasonable limitation in order to get (almost)
ANSI exception handling in Squeak, and could be fixed later or removed by
implementing a different exception handling mechanism.  

At the point I left it to refine filing code in to/out from Squeak, a
generated exception would return the correct value on EITHER resumption OR
on the termination of the process.  I'd get resumption working and break
termination.  I'd fix termination and break resumption.  I have not figured
out how to properly set the stack to the desired context and put the return
value on it correctly in Squeak.  My rudimentary test code worked fine
except for this (sort of "Other than that Mrs. Lincoln, how'd you like the
play?").

I don't want to mislead anyone, so the above must be taken in the context
that I consider myself an advanced beginner as I've been learning Smalltalk
for a couple of years on my own.  I've never worked with exceptions, so I
don't know if my hack-up of VSExceptions is pretty close or complete junk.

I am currently refining my Squeak SIF reader/writer implementation for file
in/out of ANSI SIF code to clear up a couple of problem areas:

        - The first SIF reader/writer implementation was almost
incomprehensible.

        - Different platform line termination sometimes breaks the style runs in
          a Text object when read from a file.

        - Rudimentary tracking facilities on ANSI SIF code program elements  
          filed in/out.

        - Adding the program element common annotations (author, copyright,
etc.)
          mentioned in the SIF specification to the created objects (class
author,
          pool copyright, etc.).

Once I get these squared away, I'll have the ability to file in/out ANSI SIF
code program elements with common annotations, and documentation in the
code, that I can share between platforms.

I'll then try to get exception resumption AND termination working.

Easy, isn't it?

--
Richard A. Harmon          "The only good zombie is a dead zombie"
harmonra at webname.com           E. G. McCarthy





More information about the Squeak-dev mailing list