<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=iso-8859-1">
<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;}
@font-face
        {font-family:"Calibri Light";
        panose-1:2 15 3 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;}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
        {mso-style-priority:1;
        margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.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 Eliot,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> Why not something like</p>
<p class="MsoNormal">        | p errorUnhandled errorCaught unwindBlock |</p>
<p class="MsoNormal">        unwindBlock := [[1/0] on: UnhandledError do: [errorUnhandled := true]].</p>
<p class="MsoNormal">        p := [ [ [Semaphore new wait] ensure: unwindBlock ]</p>
<p class="MsoNormal">                        on: ZeroDivide</p>
<p class="MsoNormal">                        do: [errorCaught := true] ] fork.</p>
<p class="MsoNormal">        Processor yield.</p>
<p class="MsoNormal">        self assert: p isBlocked. </p>
<p class="MsoNormal">        errorUnhandled := errorCaught := false.</p>
<p class="MsoNormal">        p terminate.</p>
<p class="MsoNormal">        self deny: errorUnhandled.</p>
<p class="MsoNormal">        self assert: errorCaught.</p>
<p class="MsoNormal">        self assert: p isTerminated!</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">yes, that's way more explicit, thanks!</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> And I see no point to the unwindBlock temporary.  Why not just put the code inline?</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">no reason, just for readability (plus I'm not sure how to nicely indent the inner nested on:do: ;) )</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for checking this.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,</p>
<p class="MsoNormal">Jaromir</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNoSpacing"><span lang="CS">--</span></p>
<p class="MsoNoSpacing"><strong><span style="font-family:"Calibri Light",sans-serif;color:#333333;font-weight:normal">Jaromír Matas</span></strong><span style="font-family:"Calibri Light",sans-serif;color:#555555"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="font-family:"Calibri Light",sans-serif;color:#2E75B6">mail@jaromir.net</span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> on behalf of Eliot Miranda <eliot.miranda@gmail.com><br>
<b>Sent:</b> Tuesday, June 7, 2022 7:45:40 PM<br>
<b>To:</b> The general-purpose Squeak developers list <squeak-dev@lists.squeakfoundation.org><br>
<b>Subject:</b> Re: [squeak-dev] The Inbox: KernelTests-jar.430.mcz</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div class="x_gmail_default" style="font-size:small">Hi Jaromir,</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Sun, Jun 5, 2022 at 2:11 PM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left-width:1px; border-left-style:solid; border-left-color:rgb(204,204,204); padding-left:1ex">
A new version of KernelTests was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/KernelTests-jar.430.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/inbox/KernelTests-jar.430.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: KernelTests-jar.430<br>
Author: jar<br>
Time: 5 June 2022, 11:11:12.187824 pm<br>
UUID: 209031e0-7bc5-984a-94dd-b3c3a24216c3<br>
Ancestors: KernelTests-jar.429<br>
<br>
Oops, fix comment in previous test KernelTests-jar.429... Sorry for the noise.<br>
<br>
=============== Diff against KernelTests-jar.429 ===============<br>
<br>
Item was changed:<br>
  ----- Method: ProcessTest>>testTerminateHandlingUnwindError (in category 'tests') -----<br>
  testTerminateHandlingUnwindError<br>
        "Test an error inside an unwind block is handled correctly."<br>
<br>
        "Workspace example:<br>
                [ [[Processor activeProcess terminate] ensure: [1/0]] on: ZeroDivide do: [] ] fork<br>
<br>
        ZeroDivide error should get caught by the handler without opening the Debugger.<br>
<br>
        To model this example as a test case we have to keep in mind that an error signal
<br>
        in one thread cannot be caught in a different thread: if process 'p' signals an error<br>
        it won't be searching for a handler in the thread that sent 'p terminate' message.<br>
        So we can't do something like:<br>
+               p := [ [ [Semaphore new wait] ensure: [1/0] ] on: ZeroDivide do: [] ] fork.<br>
-               p := [ [ [Semaphore new wait] ensure: unwindBlock ] on: ZeroDivide do: [] ] fork.<br>
                Processor yield.<br>
                self shouldnt: [p terminate] raise: Error<br>
        Instead, in order to catch the situation the ZeroDivide error is not caught within 'p',<br>
        we try to catch the UnhandledError raised in 'p' indicating the ZeroDivide has been<br>
        missed. "<br>
<br>
        | p error unwindBlock |<br>
        unwindBlock := [[1/0] on: UnhandledError do: [error := true]].<br>
        p := [ [ [Semaphore new wait] ensure: unwindBlock ] on: ZeroDivide do: [] ] fork.<br>
        Processor yield.<br>
        self assert: p isBlocked. <br>
        error := false.<br>
        p terminate.<br>
        self deny: error.<br>
        self assert: p isTerminated!<br>
<br>
</blockquote>
<div><br>
</div>
<div class="x_gmail_default" style="font-size:small">Why not something like</div>
<div class="x_gmail_default" style="font-size:small"></div>
</div>
<span style="color:rgb(0,0,0)">        | p e<span class="x_gmail_default" style="font-size:small">rrorUnhandled errorCaught</span><span class="x_gmail_default" style="font-size:small"></span> unwindBlock |</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        unwindBlock := [[1/0] on: UnhandledError do: [</span><span style="color:rgb(0,0,0)">e</span><span class="x_gmail_default" style="color:rgb(0,0,0)">rrorUnhandled</span><span style="color:rgb(0,0,0)"> := true]].</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        p := [ [ [Semaphore new wait] ensure: unwindBlock ]</span>
<div><span style="color:rgb(0,0,0)"><span class="x_gmail_default" style="font-size:small">                       
</span>on: ZeroDivide</span></div>
<div><span style="color:rgb(0,0,0)"><span class="x_gmail_default" style="font-size:small">                       
</span>do: [</span><span class="x_gmail_default" style="color:rgb(0,0,0)">errorCaught := true</span><span style="color:rgb(0,0,0)">] ] fork.</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        Processor yield.</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        self assert: p isBlocked.<span class="x_gmail-Apple-converted-space"> </span></span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        </span><span style="color:rgb(0,0,0)">e</span><span class="x_gmail_default" style="color:rgb(0,0,0)">rrorUnhandled := errorCaught</span><span class="x_gmail_default" style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,0)"> :=
 false.</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        p terminate.</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        self deny: </span><span style="color:rgb(0,0,0)">e</span><span class="x_gmail_default" style="color:rgb(0,0,0)">rrorUnhandled</span><span style="color:rgb(0,0,0)">.</span><br style="color:rgb(0,0,0)">
<span style="color:rgb(0,0,0)">        self<span class="x_gmail_default" style="font-size:small">
</span></span><span style="color:rgb(0,0,0)"><span class="x_gmail_default">assert</span>: </span><span style="color:rgb(0,0,0)">errorCaugh<span class="x_gmail_default" style="font-size:small">t</span></span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)"></span></div>
<div><span style="color:rgb(0,0,0)">        self assert: p isTerminated!</span>
<div class="x_gmail-yj6qo" style="color:rgb(0,0,0)"></div>
<br class="x_gmail-Apple-interchange-newline">
<div>
<div class="x_gmail_default" style="font-size:small">?  And I see no point to the <span style="color:rgb(0,0,0)">unwindBlock temporary.  Why not just put the code inline?</span></div>
</div>
<br>
<div dir="ltr" class="x_gmail_signature">
<div dir="ltr">
<div><span style="font-size:small; border-collapse:separate">
<div>_,,,^..^,,,_<br>
</div>
<div>best, Eliot</div>
</span></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>