[PATCH] Backwards-incompatible tweak to #on:do: with resumable exceptions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Backwards-incompatible tweak to #on:do: with resumable exceptions

Paolo Bonzini-2
This makes #on:do: fully ANSI compliant by ensuring that falling off an
exception handler will *always* leave the #on:do: block.  The previous
behavior was to resume for resumable exceptions and return for
non-resumable exceptions.

The previous behavior of GNU Smalltalk was implemented also by Visual
Smalltalk Express (VSE), the very source of the ANSI standard exception
mechanism.  The VSE and GST behavior was by design meant to "do the
right thing" in various default situations: the "right thing" for a
resumable exception whose handler "returned normally" (ran of the end of
the  block) was to resume while the "right thing" for a non-resumable
exception was to return.

Citing Allen Wirfs-Brock, the ANSI group "ultimately [decided] requiring
that the user always explicitly request resumption would result in fewer
subtle bugs.".

BTW, this change is necessary for Seaside, which relies on this in its
implementation of #call:/#answer (not that it wouldn't be possible to
patch Seaside instead -- but this is arguably a bug).

Note to self: try to understand what happens for other dialects when the
default handler is reached with #pass.  Should the exception resume or
return?

Paolo

diff --git a/ChangeLog b/ChangeLog
index 3f1e5c0..2c9ce9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-25  Paolo Bonzini  <[hidden email]>
+
+ * kernel/AnsiExcept.st: Upon executing off the end of an
+ exception handler, always return from the associated #on:do:.
+
 2008-02-22  Paolo Bonzini  <[hidden email]>
 
  * kernel/AnsiDates.st: Add #date:time:offset:, #date:time:.
diff --git a/NEWS b/NEWS
index 1930c0f..2221fce 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,11 @@ o   ObjectMemory>>#snapshot and ObjectMemory>>#snapshot: return false in
     snapshot.  Note that this does not apply to CallinProcesses, since
     those are stopped in saved images (will this be true in 3.1?).
 
+o   The semantics of #on:do: were changed: executing off the end of an
+    exception handler will always return from the associated #on:do:.
+    Older versions of GNU Smalltalk either returned or resumed depending
+    on the resumability of the exception.
+
 o   New tool gst-remote allows remote control of a GNU Smalltalk VM
     via a TCP socket.
 
diff --git a/kernel/AnsiExcept.st b/kernel/AnsiExcept.st
index 8e45f44..4b71afd 100644
--- a/kernel/AnsiExcept.st
+++ b/kernel/AnsiExcept.st
@@ -213,7 +213,7 @@ CoreException, so the two mechanisms are actually interchangeable.'>
 
  <category: 'exception signaling'>
  self exception instantiateNextHandler: self.
- ^self activateHandler: self isResumable
+ ^self activateHandler: (onDoBlock isNil and: [ self isResumable ])
     ]
 
     signal: messageText [

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk