Hi Jaromir,<br>
<br>
Thanks for working on this! I'm possibly a bit late on the party, but I noticed that current #signal only keeps the messageText, not any other custom properties of an exception. I'm not sure whether this is the expected behavior. :)<br>
<br>
Think of this revised example:<br>
<br>
    [(KeyNotFound key: #plonk) signal] on: Error do: [:ex |<br>
        [ex signal] on: KeyNotFound do: [:ex2 | Transcript show: ex2]]<br>
<br>
It will print out "Key not found: nil" to the Transcript, instead of printing the original key.<br>
<br>
Without diving deeper into this discussion, my first impression would have been that some kind of #freshCopy (maybe with a better name?) would be a more holistic approach to honor any state in subclasses of Exception. What do you think? :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
<br>
On 2022-02-06T11:42:46+01:00, mail@jaromir.net wrote:<br>
<br>
> Hi,<br>
> just an update: I've sent a proposal to the Inbox: Kernel-jar.1446 with the following code:<br>
> <br>
> signal<br>
>     "Ask ContextHandlers in the sender chain to handle this signal.  The default is to execute and return my defaultAction.<br>
>     Sending #signal to an already signaled exception generates a new exception of the same type with the same messageText"<br>
> <br>
>     signalContext ifNotNil: [^self class signal: messageText]. <br>
>     signalContext := thisContext contextTag.<br>
>     ^(thisContext nextHandlerContextForSignal: self) handleSignal: self<br>
> <br>
> If possible I'd like to withdraw my previous contribution to #signal making repeated #signal sends equivalent to sending #outer, to prevent future code from using that misleading approach. Subsequent #signal sends are NOT equivalent to #outer and they have their own subtly different meaning discussed here - provided my interpretation of ANSI is right this time :)<br>
> <br>
> Thanks for your time and apologies for previous confusion.<br>
> <br>
> best, <br>
> Jaromir<br>
> ^[^    <br>
>   --<br>
> Sent from Squeak Inbox Talk<br>
> <br>
> On 2022-02-05T18:48:39+01:00, mail at jaromir.net wrote:<br>
> <br>
> > Hi Chris,<br>
> > <br>
> > On 2022-02-04T17:11:35-06:00, asqueaker at gmail.com wrote:<br>
> > <br>
> > > Hi Jaromir,<br>
> > > <br>
> > > Here's a motivation example:<br>
> > > ><br>
> > > > [1/0] on: Error do: [:ex |<br>
> > > >         [ex signal] on: ZeroDivide do: [Transcript show: #ZeroDivide]<br>
> > > >         ]<br>
> > > ><br>
> > > > Would you expect this code to work and pick up the ZeroDivide handler?<br>
> > > ><br>
> > > ...<br>
> > > <br>
> > > > The point or a use case is to provide additional (finer, more specific)<br>
> > > > handlers inside the general handler rather than wrap the general handler<br>
> > > > inside more specific handlers. More specific handlers can even be inside a<br>
> > > > method so the readability would not degrade.<br>
> > > ><br>
> > > <br>
> > > I was able to do it by creating a new exception instance and signaling it:<br>
> > > <br>
> > >     [1/0] on: Error do: [: err |<br>
> > >             [err copy signal] on: ZeroDivide do: [Transcript show:<br>
> > > #ZeroDivide] ]<br>
> > > <br>
> > > I don't know about #copy, though, you might want to implement your own<br>
> > > special #freshCopy that throws out the signalContext, handlerContext and<br>
> > > outerContext, but the above "worked".  :)<br>
> > > <br>
> > <br>
> > Precisely, it crossed my mind too and yes, it has to be a "fresh" copy with blank instance variables (except messageText). A simple copy fails tests with nested outer etc...<br>
> > <br>
> > I've checked ANSI again and they say, quote: [5.5.3.1 messageText][...] Subsequent sends of of the message #messageText to a signaled exception generated by sending the message #signal to the receiver of this message [note: the receiver is an exception instance] will also return this value.<br>
> > <br>
> > So what I'm actually looking for is this: (and it's equivalent to the "fresh" copy idea)<br>
> > <br>
> >     [1/0] on: Error do: [: err |  <br>
> >             [err class signal: err messageText] on: ZeroDivide do: [Transcript show: #ZeroDivide] ]<br>
> > <br>
> > If I'm interpreting ANSI's intention correctly then we could update our #signal like this:<br>
> > <br>
> > signal<br>
> >     "Ask ContextHandlers in the sender chain to handle this signal.  The default is to execute and return my defaultAction.<br>
> >     Signaling an already signaled exception is interpreted as signaling a new exception of the same type with the same messageText"<br>
> > <br>
> > -    signalContext ifNotNil: [^self outer].<br>
> > +    signalContext ifNotNil: [^self copy signal: self messageText]. <br>
> >     signalContext := thisContext contextTag.<br>
> >     ^(thisContext nextHandlerContextForSignal: self) handleSignal: self<br>
> > <br>
> > It was my idea last year to make subsequent sends of #signal to an already signaled exception equivalent to #outer and now I can see it was wrong and I'd like to really fix it this time :) All test are green, even the ones in Tests-jar.464.<br>
> > <br>
> > Thanks, Chris, for discussing this.<br>
> > <br>
> > best, <br>
> > Jaromir<br>
> > ^[^    <br>
> >   --<br>
> > Sent from Squeak Inbox Talk<br>
> > <br>
> ><br>
> <br>