<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;}
@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;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
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,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">>> What is the purpose of the primitive 196 Context>>#terminateTo:?
</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> Strongly related to prim 195 & 197. You have to check each context up the chain to see what exceptions might be dealt with & by which context.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My understanding is prim 195 (#findNextUnwindContextUpTo:) searches for unwind contexts and prim 197 (#findNextHandlerContextStarting) searches for handler context. But prim 195 (#terminateTo:) is unclear to me. #terminateTo comment says:</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">"Terminate all the Contexts between me and previousContext, if previousContext is on my Context stack. Make previousContext my sender."</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Which doesn't say much except it's nilling all context's pc and sender between self and the argument. I wonder what else it does behind the scenes and why :)</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In a paper from 2009 Eliot wrote:</p>
<p class="MsoNormal">"[...] there’s a primitive terminateTo: that does something similar to the context nilling in non-local return. It is a little simpler than non-local return (although not much) but it is just a variation on the same theme so I’ll spare
 you."</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I wish Eliot didn't spare us :) Other than that I haven't found any further info.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Because the primitive 196 dates back to 2001 I'm unable to judge whether it's still essential to nil the intermediate contexts (to free stack pages or something).
</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In particular I'm trying to understand whether the use of #terminateTo *<b>primitive</b>* in #resumeEvaluating: and #resume:through: is essential or not.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any additional info greatly appreciated.</p>
<p class="MsoNormal">Thanks,</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<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#8FAADC"><o:p> </o:p></span></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:tim@rowledge.org">tim Rowledge</a><br>
<b>Sent: </b>Sunday, February 12, 2023 5:18<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] Questions about FullBlock closures</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
> On 2023-02-11, at 4:04 PM, Jaromir Matas <mail@jaromir.net> wrote:<br>
> <br>
> If I may, I have a question here: What is the purpose of the primitive 196 Context>>#terminateTo:? Why primitive and why terminating each context along the way? Naively, I'd think checking the two contexts are in the same sender chain and patching them via
 privSender should do but I'm sure I'm missing something here :)<br>
>  <br>
<br>
Exception handling stuff. Strongly related to prim 195 & 197. You have to check each context up the chain to see what exceptions might be dealt with & by which context. Look at e.g. Process>>#terminate for some context.<br>
<br>
<br>
tim<br>
--<br>
tim Rowledge; tim@rowledge.org; <a href="http://www.rowledge.org/tim">http://www.rowledge.org/tim</a><br>
When flying inverted, remember that down is up and up is expensive<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>