<p>I think if it interprets pushThisContext and a push and a send to #return:, It have to simulate return of the value of the push (next to pushThisContext) but I don&#39;t know how to hack it.</p>
<p>- Jin-oh -</p>
<div class="gmail_quote">2012. 3. 14. ¿ÀÀü 3:37¿¡ &quot;Eliot Miranda&quot; &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;´ÔÀÌ ÀÛ¼º:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Yoshiki, &nbsp;Hi Hans-Martin, Hi All,<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 10:25 AM, Yoshiki Ohshima <span dir="ltr">&lt;<a href="mailto:Yoshiki.Ohshima@acm.org" target="_blank">Yoshiki.Ohshima@acm.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">At Tue, 13 Mar 2012 10:08:12 -0700,<br>
<div>Eliot Miranda wrote:<br>
&gt;<br>
&gt; In this case&nbsp;runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo&gt;test and the result to be returned (42). &nbsp;But instead it answers the activation of Foo&gt;test<br>
&gt; and nil. &nbsp;Hence the return in ContextPart&gt;return: isn&#39;t simulated and control passes to the next statement, ^666.<br>
&gt;<br>
&gt; Once again I&#39;m drawn into the bowels of&nbsp;runUntilErrorOrReturnFrom:<br>
&gt; :) It is my nemesis.<br>
<br>
</div>This seems close to the realm of magic to me. &nbsp;Thank you for looking<br>
into it!<br></blockquote><div><br></div><div>Alas, I find it near to magic too. &nbsp;I understand what&#39;s going on. &nbsp;The terminateTo: call in resume: doesn&#39;t trip the unwind-protect in&nbsp;runUntilErrorOrReturnFrom: (as it shouldn&#39;t; terminateTo: specifically doesn&#39;t run unwinds by design). &nbsp;So&nbsp;runUntilErrorOrReturnFrom: doesn&#39;t answer the right context to resume. &nbsp;It answers Foo&gt;test instead of Foo&gt;test&#39;s sender.</div>

<div><br></div><div>What I don&#39;t understand is what is a valid criterion for determining these cases. &nbsp;I can hack the method, special casing it for ContextPart&gt;return: and ContextPart&gt;resume:, but that&#39;s not acceptable. &nbsp;So if anyone has the desire to pair on this let me know. &nbsp;Perhaps we could have a go at it over skype sometime soon (not today; already blown a lot of time looking at this ;) ).</div>

<div><br></div><div>In any case I&#39;ve attached two versions of&nbsp;runUntilErrorOrReturnFrom:, one instrumented, one not,&nbsp;containing a hack that gets the right answer (in this case). &nbsp;Yoshiki, you might play with the uninstrumented one to get you going. &nbsp;Hans-Martin, I think you&#39;re one of very few people who could shed light on this.</div>

<div><br></div><div>To use the instrumented one (which prints its arguments and halts between evaluation and deciding what to return) step the debugger up to e.g. the send of return:, inspect thisContext (the context about to be sent return:) and set ContextPart&#39;s class var QuickStep to that context (in the inspector evaluate QuickStep := self). &nbsp;Then do step.&nbsp;</div>

<div><br></div><div>At least the hack doesn&#39;t make things worse; the tests appear the same.</div><div><br></div><div>So one thing to do is to play with the hack, ad see if it causes problems. &nbsp;Another thing to do is to think about the criterion in the hacked&nbsp;runUntilErrorOrReturnFrom: when one should return from the receiver&#39;s receiver, rather from aSender&#39;s sender.</div>

<div><br></div><div>I&#39;m cc&#39;ing the Pharo list. &nbsp;Here&#39;s Yoshiki&#39;s original message and a substantive reply of mine:</div><div><br></div><div><br></div><div>On Tue, Mar 13, 2012 at 3:27 AM, Yoshiki Ohshima&nbsp;<span dir="ltr">&lt;<a href="mailto:Yoshiki.Ohshima@acm.org" target="_blank">Yoshiki.Ohshima@acm.org</a>&gt;</span>&nbsp;wrote:<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>&nbsp;Hello,<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>I noticed that step executing the following code in debugger yields<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>different results:<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>-------------------<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>test<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp;3 &lt; 4 ifTrue: [<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;thisContext return: 42].<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>&nbsp; &nbsp; &nbsp; &nbsp;^ 666.<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>-------------------<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>In the normal execution, you get 42 as expected, but if you debug it<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>and step execute, #return: does not actually return and you get 666.<br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>

<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>It appears that the primitive for #terminateTo: is the culprit...<br>

<font color="#888888"><br></font><font color="#888888">-- Yoshiki</font></div><div><font color="#888888"><br></font></div><div>On Tue, Mar 13, 2012 at 10:08 AM, Eliot Miranda&nbsp;<span dir="ltr" style>&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span>&nbsp;wrote:<br>

<blockquote class="gmail_quote" style="padding-left:1ex;margin-right:0px;border-left-color:rgb(204,204,204);border-left-style:solid;margin-left:0.8ex;margin-bottom:0px;margin-top:0px;border-left-width:1px">
</blockquote>Hi Yoshiki,<br><br>From what I can see so far it is the return value from runUntilErrorOrReturnFrom: in complete: when the debugger executes test&#39;s return: call. &nbsp;i.e. the debugged process is in Foo&gt;&gt;test at pc 43:<br>

<br>37 &lt;22&gt; pushConstant: 3<br>38 &lt;23&gt; pushConstant: 4<br>39 &lt;B2&gt; send: &lt;<br>40 &lt;9B&gt; jumpFalse: 45<br>41 &lt;89&gt; pushThisContext:&nbsp;<br>42 &lt;21&gt; pushConstant: 42<br>43 &lt;E0&gt; send: return:<br>

44 &lt;87&gt; pop<br>45 &lt;24&gt; pushConstant: 666<br>46 &lt;7C&gt; returnTop<br><br>The stack in the debugger is&nbsp;<br>Process&gt;&gt;complete:<br>Process&gt;&gt;completeStep:<br>Debugger&gt;&gt;doStep<br><br><br><br>and Process&gt;complete: is&nbsp;<br>

<br>complete: aContext&nbsp;<br><span style="white-space:pre-wrap">        </span>&quot;Run self until aContext is popped or an unhandled error is raised. &nbsp;Return self&#39;s new top context, unless an unhandled error was raised then return the signaler context (rather than open a debugger).&quot;<br>

<span style="white-space:pre-wrap">        </span><br><span style="white-space:pre-wrap">        </span>| ctxt pair error |<br><span style="white-space:pre-wrap">        </span>ctxt := suspendedContext.<br><span style="white-space:pre-wrap">        </span>suspendedContext := nil. &nbsp;&quot;disable this process while running its stack in active process below&quot;<br>

<span style="white-space:pre-wrap">        </span>pair := ctxt runUntilErrorOrReturnFrom: aContext.<br><span style="white-space:pre-wrap">        </span>suspendedContext := pair first.<br><span style="white-space:pre-wrap">        </span>error := pair second.<br>

<span style="white-space:pre-wrap">        </span>error ifNotNil: [^ error signalerContext].<br><span style="white-space:pre-wrap">        </span>^ suspendedContext<br><br>where the receiver is the activation of Foo&gt;test, and aContext is the activation of ContextPart&gt;return: (whose receiver is also the receiver of complete:, the activation of Foo&gt;test).<br>

<br>In this case&nbsp;runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo&gt;test and the result to be returned (42). &nbsp;But instead it answers the activation of Foo&gt;test and nil. &nbsp;Hence the return in ContextPart&gt;return: isn&#39;t simulated and control passes to the next statement, ^666.<br>

<br>Once again I&#39;m drawn into the bowels of&nbsp;runUntilErrorOrReturnFrom: :) It is my nemesis.<br><span style="color:rgb(136,136,136)">--&nbsp;</span><br><span style="color:rgb(136,136,136)">best,</span><br>
<font color="#888888"><div>Eliot</div></font></div><div>--&nbsp;</div></div>best,<div>Eliot</div><br>
<br><br>
<br></blockquote></div>