<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Vaidotas,<o:p></o:p></p>
<p class="MsoNormal">Thanks for the feedback; great example… I’ll investigate. I plan to revisit exceptions later and let you know :)<o:p></o:p></p>
<p class="MsoNormal">Thanks again,<o:p></o:p></p>
<p class="MsoNormal">Jaromir<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:vaidasd@gmail.com">Vaidotas Didžbalis</a><br>
<b>Sent: </b>Monday, March 7, 2022 17:15<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">The general-purpose Squeak developers list</a><br>
<b>Subject: </b>Re: [squeak-dev] Slightly incorrect implementation of #resignalAs: ??</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">Hello Jaromir, all, <o:p></o:p></p>
<div>
<p class="MsoNormal">Change affects re-signaling exceptions of the same kind, line below falls into endless loop in Trunk. It works differently in Squeak 5.3 or 4.2:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[Error new signal: 'some error'] on: Error do: [:e | e resignalAs: (DomainError new messageText: 'some domain error')].<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Vaidotas<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Fri, Feb 4, 2022 at 4:15 PM <<a href="mailto:mail@jaromir.net">mail@jaromir.net</a>> wrote:<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:4.8pt">
Hi Jakob, all,<br>
<br>
I give up this experiment of mine; I've realized using #restartWithNewReceiver is tricky and very non-OOP: replacing a receiver with an object of a different type introduces unexpected consequences and checking the type of the replacement object is so not-object-oriented;
 the best I could come up with is:<br>
<br>
resignalAs: replacementException<br>
        "Signal an alternative exception in place of the receiver."<br>
<br>
        (replacementException isKindOf: Exception class) ifTrue: [^self resignalAs: replacementException new].<br>
        (replacementException isKindOf: Exception) ifFalse: [^self error: 'wrong replacementException type'].<br>
        signalContext restartWithNewReceiver: replacementException<br>
<br>
This would be a clean implementation of ANSI's #resignalAs with a nice stack when debugging; compare with the confusing stack currently produced for e.g.:<br>
<br>
        [self error] on: Error do: [:ex | ex resignalAs: Warning new]<br>
<br>
Besides, the current implementation allows nonsense like this evaluate silently:<br>
<br>
        [self error] on: Error do: [:ex | ex resignalAs: Semaphore new] <br>
<br>
but it probably doesn't do much harm and doesn't justify changing the current simple implementation.<br>
<br>
So unless someone sees any value in the above implementation I won't clutter the Inbox :)<br>
<br>
Thanks.<br>
<br>
best, <br>
Jaromir<br>
^[^    <br>
  --<br>
Sent from Squeak Inbox Talk<br>
<br>
On 2022-01-29T21:43:17+01:00, <a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a> wrote:<br>
<br>
> Hi Jakob, <br>
>       a correction:<br>
> <br>
> > > As so often, the breaking of applications that relied on the<br>
> > > non-standard behavior may be an obstacle.<br>
> > Yes indeed, that's a pain... theoretically as a workaround a class method could be added to create an instance and send it the instance side #resignalAs.
<br>
> <br>
> Sorry, ignore me please, no class method indeed, but something like this:<br>
> <br>
> resignalAs: replacementException<br>
>       "Abort an exception handler and signal an alternative exception in place of the receiver.<br>
>        Allow an exception class as replacementException as an extension of ANSI specification:<br>
>               [1/0] on: Error do: [:ex | ex resignalAs: Warning new]    <--- ANSI compliant<br>
>               [1/0] on: Error do: [:ex | ex resignalAs: Warning]           <--- Squeak extension"<br>
> <br>
>       (replacementException isKindOf: Exception class) ifTrue: [<br>
>               self resignalAs: replacementException new].<br>
>       signalContext restartWithNewReceiver: replacementException<br>
> <br>
> a bit ugly... Or keep it simple, no extension?<br>
> <br>
> resignalAs: replacementException<br>
>       "Abort an exception handler and signal an alternative exception in place of the receiver."<br>
> <br>
>       signalContext restartWithNewReceiver: replacementException<br>
> <br>
> best,<br>
> ~~~<br>
> ^[^    Jaromir<br>
> <br>
> Sent from Squeak Inbox Talk<br>
> <br>
> On 2022-01-29T20:18:40+01:00, mail at <a href="http://jaromir.net" target="_blank">
jaromir.net</a> wrote:<br>
> <br>
> > Hi Jakob,<br>
> > <br>
> > thanks for your reply. <br>
> > <br>
> > The proposed change is not supposed to change the semantics of resignalAs in any way (except limiting the argument to an exception instance, not a class).<br>
> > <br>
> > We already have 3 resignalAs tests - is this ok? Pharo/Cuis are behind Squeak and as for VW I'm not familiar with their testing just yet.<br>
> > <br>
> > The tests are green; well, after fixing my own contribution from last year (doubleOuterResignalAsTest) where I erroneously used a class as #resignalAs's argument - what a shame :) I'll definitely send a fix of this test to the Inbox.<br>
> > <br>
> > > As so often, the breaking of applications that relied on the<br>
> > > non-standard behavior may be an obstacle.<br>
> > Yes indeed, that's a pain... theoretically as a workaround a class method could be added to create an instance and send it the instance side #resignalAs. However looking at its senders this method doesn't feel like frequently used :) (VA didn't even bother
 to implement it, at least in the version I have)<br>
> > <br>
> > best,<br>
> > ~~~<br>
> > ^[^    Jaromir<br>
> > <br>
> > Sent from Squeak Inbox Talk<br>
> > <br>
> > On 2022-01-29T18:53:24+01:00, jakres+squeak at <a href="http://gmail.com" target="_blank">
gmail.com</a> wrote:<br>
> > <br>
> > > Hi Jaromir,<br>
> > > <br>
> > > We should start with a test case. I agree with your interpretation of<br>
> > > the standard and see no harm in an inbox submission.<br>
> > > Is there some ANSI Smalltalk test suite out there that could be shared<br>
> > > between the dialects?<br>
> > > <br>
> > > As so often, the breaking of applications that relied on the<br>
> > > non-standard behavior may be an obstacle.<br>
> > > <br>
> > > Kind regards,<br>
> > > Jakob<br>
> > > <br>
> > > Am Sa., 29. Jan. 2022 um 17:43 Uhr schrieb <mail at <a href="http://jaromir.net" target="_blank">
jaromir.net</a>>:<br>
> > > ><br>
> > > > Hi all,<br>
> > > ><br>
> > > > I think Squeak's implementation of #resignalAs: is not following the ANSI specification precisely. Currently it reads:<br>
> > > ><br>
> > > > resignalAs: replacementException<br>
> > > ><br>
> > > >         signalContext resumeEvaluating: [replacementException signal]<br>
> > > ><br>
> > > > ANSI says:<br>
> > > > "<br>
> > > > The active exception action is aborted and the exception environment *and the evaluation context*<br>
> > > > are restored to the same states that were in effect when the receiver was originally signaled.<br>
> > > > This message (i.e. resignalAs:) causes the replacementException to be treated as if it had been originally<br>
> > > > signaled instead of the receiver.<br>
> > > > "<br>
> > > ><br>
> > > > This is very similar to #retry (or #retryUsing:) specification so I'd suggest the following implementation:<br>
> > > ><br>
> > > > resignalAs: replacementException<br>
> > > ><br>
> > > >         signalContext restartWithNewReceiver: replacementException<br>
> > > ><br>
> > > > The current implementation leads to building the new resignaled contexts on top of the previous signal contexts (and the resignalAs context itself) instead of simply *restarting* the previous signal context with the replacement exception as the new
 receiver. In my opinion the suggested implementation precisely follows the ANSI specification, and is consistent with current #retry and #retryUsing: implementation - compare:<br>
> > > ><br>
> > > > retryUsing: alternativeBlock<br>
> > > >         "Abort an exception handler and evaluate a new block in place of the handler's protected block."<br>
> > > ><br>
> > > >         handlerContext restartWithNewReceiver: alternativeBlock<br>
> > > ><br>
> > > > Other dialects: Pharo and Cuis copied Squeak's but VW implemented resignalAs: to comply with ANSI precisely.<br>
> > > ><br>
> > > > One consideration: the current implementation allows "exception resignalAs: Error", i.e. allows Exception class as an argument but ANSI's version requires "exception resignalAs: Error new". All senders (there are just a few) in the base image seem use
 "Error new" anyway.<br>
> > > ><br>
> > > > My arguments for are: consistency, readability and less complexity (especially while debugging)<br>
> > > ><br>
> > > > What do you think? Inbox it?<br>
> > > ><br>
> > > > best,<br>
> > > > ~~~<br>
> > > > ^[^    Jaromir<br>
> > > ><br>
> > > > Sent from Squeak Inbox Talk<br>
> > > ><br>
> > > <br>
> > ><br>
> > <br>
> ><br>
> <br>
> <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>