<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'>Thank you. <br><br>I had the mis-conception of 1 MethodContext representing the code in that Doit.<br><br>From the BlueBook<br><br><br><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>A MethodContext ...&nbsp; Represents the execution of a CompiledMethod in<b> response to a message.</b></div></blockquote> <br><br><br><br>Funny how you can read a thing a dozen times and until you try to do something with it, you don't really understand it.<br><br>Thanks again for your help.<br><br><br><div id="1"><br>---- On Wed, 01 Jan 2014 14:15:01 -0800 <b>Ryan Macnak&lt;rmacnak@gmail.com&gt;</b> wrote ---- <br></div><br><blockquote style="border-left: 1px solid #0000FF; padding-left: 6px; margin:0 0 0 5px"> <div dir="ltr"><br><div><br><br><div>On Wed, Jan 1, 2014 at 2:55 PM, gettimothy <span dir="ltr">&lt;<a subj="" mailid="gettimothy%40zoho.com" href="mailto:gettimothy@zoho.com" target="_blank">gettimothy@zoho.com</a>&gt;</span> wrote:<br> <blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">&nbsp;<br><u></u><div><div style="font-size:10pt;font-family:verdana,arial,helvetica,sans-serif"> In Eliot's first example on <a href="http://www.mirandabanda.org/cogblog/category/cog/page/14/" target="_blank">fixing the reentrancy problem</a> that uses "factorial copy" for the recursion.<br><br>I modifed his code:<br> <br><font face="serif"></font><br><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)"><div><font face="serif">&nbsp;&nbsp; | factorial |<br>         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;factorial := [:n| n = 1 ifTrue: [1] ifFalse: [(factorial copy value: n - 1) * n]].<br>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(1 to: 10) collect: factorial copy</font></div></blockquote> <br><br>into something I could trace out a bit easier.<br><br><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)"> <div><br>| factorial fc |<br>Transcript clear.<br>factorial := [:n&nbsp; |<br>&nbsp;&nbsp;&nbsp; n = 1 <br>&nbsp;&nbsp;&nbsp; ifTrue:[&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: ' n=',&nbsp; (n asString),' ', (thisContext class name), '(',&nbsp; (thisContext identityHash asString),')' .<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: '--sender--&gt;', (thisContext sender) class name, '(',&nbsp;&nbsp; (thisContext sender) identityHash asString,')'. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: '--home--&gt;', (thisContext home) class name,&nbsp; '(', (thisContext home) identityHash asString,')'; cr. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: '++++++++++++++++++++++++++++++++++++++++';cr. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; "thisContext explore.&nbsp;&nbsp;&nbsp; "<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; ] <br>&nbsp;&nbsp;&nbsp; ifFalse:[&nbsp;&nbsp;&nbsp; Transcript show: '-----------------------------------------------';cr. <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: ' n=',&nbsp; (n asString),' ', (thisContext class name), '(',&nbsp; (thisContext identityHash asString),')' .<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: '--sender--&gt;', (thisContext sender) class name, '(',&nbsp;&nbsp; (thisContext sender) identityHash asString,')'. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Transcript show: '--home--&gt;', (thisContext home) class name,&nbsp; '(', (thisContext home) identityHash asString,')'; cr. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (factorial copy value: n-1) * n<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ]].<br>Transcript show:' factorial = ' , (factorial class name),'(',factorial identityHash asString,')'. &nbsp;&nbsp;&nbsp; <br>Transcript show: '--sender--&gt;', (factorial sender) class name, '(',&nbsp;&nbsp; (factorial sender) identityHash asString,')'. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> Transcript show: '--home--&gt;', (factorial home) class name,&nbsp; '(', (factorial home) identityHash asString,')'; cr. &nbsp;&nbsp;&nbsp; <br>Transcript show: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^';cr. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> fc := factorial copy .<br><br>Transcript show:' fc = ' , (fc class name),'(',fc identityHash asString,')'. &nbsp;&nbsp;&nbsp; <br>Transcript show: '--sender--&gt;', (fc sender) class name, '(',&nbsp;&nbsp; (fc sender) identityHash asString,')'. &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> Transcript show: '--home--&gt;', (fc home) class name,&nbsp; '(', (fc home) identityHash asString,')'; cr. &nbsp;&nbsp;&nbsp; <br>Transcript show: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^';cr. &nbsp;&nbsp;&nbsp; <br> <br>thisContext inspect.<br>factorial inspect.<br>fc inspect.<br>(1 to: 3) collect: fc</div></blockquote> <br><br><br>The Transcript output is as follows:<br><br><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)"> <div><br>&nbsp;factorial = BlockContext(694)--sender--&gt;UndefinedObject(3840)--home--&gt;MethodContext(2677)<br>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>&nbsp;fc = BlockContext(3934)--sender--&gt;UndefinedObject(3840)--home--&gt;MethodContext(2677)<br> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>&nbsp;n=1 BlockContext(3934)--sender--&gt;MethodContext(2367)--home--&gt;MethodContext(2677)<br>++++++++++++++++++++++++++++++++++++++++<br>-----------------------------------------------<br> &nbsp;n=2 BlockContext(3934)--sender--&gt;MethodContext(2367)--home--&gt;MethodContext(2677)<br>&nbsp;n=1 BlockContext(1198)--sender--&gt;BlockContext(3934)--home--&gt;MethodContext(2677)<br>++++++++++++++++++++++++++++++++++++++++<br> -----------------------------------------------<br>&nbsp;n=3 BlockContext(3934)--sender--&gt;MethodContext(2367)--home--&gt;MethodContext(2677)<br>-----------------------------------------------<br>&nbsp;n=2 BlockContext(1684)--sender--&gt;BlockContext(3934)--home--&gt;MethodContext(2677)<br> &nbsp;n=1 BlockContext(2780)--sender--&gt;BlockContext(1684)--home--&gt;MethodContext(2677)<br>++++++++++++++++++++++++++++++++++++++++</div></blockquote> <br><br><a href="http://www.mirandabanda.org/cogblog/category/cog/page/14/" target="_blank"></a><br> Look at the 3'rd line, where n=1. <br>Why is the sender--&gt;MethodContext(2367) instead of sender--&gt;MethodContext(2677)<br>What created that new MethodContext?<br></div></div></blockquote><div><br></div><div>That would be the activation of Interval&gt;&gt;collect:, which performs the first call of the copied factorial block for each 1 through 3.</div> <div><br></div><div>collect: aBlock</div><div><span style="white-space:pre">        </span>| nextValue result |</div><div><span style="white-space:pre">        </span>result := self species new: self size.</div><div><span style="white-space:pre">        </span>nextValue := start.</div> <div><span style="white-space:pre">        </span>1 to: result size do:</div><div><span style="white-space:pre">                </span>[:i |</div><div><span style="white-space:pre">                </span>result at: i put: (<b><u>aBlock value: nextValue</u></b>).</div> <div><span style="white-space:pre">                </span>nextValue := nextValue + step].</div><div><span style="white-space:pre">        </span>^ result&nbsp;</div></div><br></div></div> </blockquote><br></div></body></html>