Hi All,
Until recently signalling an already existing exception object have lead to an error. As a temporary measure we made sending #signal to an exception equivalent to #outer ([1] and [2]); however, according to ANSI re-signalling an existing exception should be legitimate and differs from sending #outer in that the search for its handler starts from the current context rather than from the exception's handler context. I'd like to propose a full implementation of repeated #signal sends to an existing exception consistent with ANSI; the implementation is surprisingly simple: it deals with the chain of repeated #signal sends in the same manner as #outer, i.e. stores the corresponding signal and handler contexts as context's local variables. See implementation in [3] and tests in [4].
To illustrate the difference between re-signaling and sending #outer compare these two examples:
[Notification signal]
on: Notification
do: [:ex1 |
[ex1 signal. Transcript showln: 'hello from outer']
on: Notification
do: [:ex2 | Transcript showln: 'hello from re-signal']]
versus:
[Notification signal]
on: Notification
do: [:ex1 |
[ex1 outer. Transcript showln: 'hello from outer']
on: Notification
do: [:ex2 | Transcript showln: 'hello from re-signal']]
In the first example the second signal found the ex2 handler because it was the most recent Notification handler on the stack.
In the second example #outer started searching from its handler context and reached the default handler (the ex2 handler was out of #outer's scope).
I've included test cases based on these two scenarios in [4].
The truth is nobody (almost) is using #outer which on the other hand could have been because the implementation was buggy. With regard to a previous discussion in [5] there shouldn't be any portability issues because each Smalltalk implementation is dealing with re-signaling and #outer differently.
Thanks for your input :)
[1]
http://forum.world.st/The-Trunk-Kernel-jar-1400-mcz-td5129445.html[2]
http://forum.world.st/The-Inbox-Kernel-jar-1399-mcz-tp5129370p5129437.html[3]
http://forum.world.st/The-Inbox-Kernel-jar-1407-mcz-td5129709.html[4]
http://forum.world.st/The-Inbox-Tests-jar-464-mcz-td5129710.html[5]
http://forum.world.st/The-Inbox-Kernel-jar-1399-mcz-tp5129370p5129435.htmlbest,
^[^ Jaromir