<br><br><div class="gmail_quote">On Sun, Apr 15, 2012 at 1:22 AM, Guillermo Polito <span dir="ltr">&lt;<a href="mailto:guillermopolito@gmail.com">guillermopolito@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
b := [ |a| a:=2 ].<br>b asContext tempNames -&gt;  #(&#39;a&#39;)<br>b asContext tempNamed: &#39;a&#39; -&gt; Boom in MethodContext&gt;&gt;#tempAt: primitive<br><br>tempAt: in Method context uses &lt;primitive: 210&gt;, which is failing.  Maybe there is a new primitive we are not aware of for Blocks...</blockquote>
<div><br></div><div>No, 210 is what is needed.   The issue is my implementation of temporary initialization in blocks, which simply uses pushNil to allocate and initialize each temp. So if one inspects [|a|a:=2] and sends it self method symbolic you get:</div>
<div><br></div><div><div>13 &lt;8F 00 00 05&gt; closureNumCopied: 0 numArgs: 0 bytes 17 to 21</div><div>17 <span class="Apple-tab-span" style="white-space:pre">        </span>&lt;73&gt; pushConstant: nil</div><div>18 <span class="Apple-tab-span" style="white-space:pre">        </span>&lt;77&gt; pushConstant: 2</div>
<div>19 <span class="Apple-tab-span" style="white-space:pre">        </span>&lt;81 40&gt; storeIntoTemp: 0</div><div>21 <span class="Apple-tab-span" style="white-space:pre">        </span>&lt;7D&gt; blockReturn</div><div>22 &lt;7C&gt; returnTop</div>
</div><div><br></div><div>And when you say self asContext pc you get 17, which is *before* the nil is pushed.  So you&#39;ll want to modify tempNamed: to compare the index of the temporary with the stack pointer and answer nil if the index is beyond the stack pointer.</div>
<div><br></div><div>The same bug exists in Squeak, e.g. the below gave an error until I fixed DebuggerMethodMap&gt;&gt;namedTempAt:in:</div><div><br></div><div><div><br></div><div>| b |</div><div>b := [ |a| a:=2 ].</div><div>
{ b asContext tempNames. b method debuggerMap tempsAndValuesForContext: b asContext }</div><div>#(#(&#39;b&#39; &#39;a&#39;) &#39;b: <span class="Apple-tab-span" style="white-space:pre">        </span>[closure] in UndefinedObject&gt;&gt;DoIt</div>
<div>a: <span class="Apple-tab-span" style="white-space:pre">        </span>nil</div><div>&#39;)</div></div><div><br></div><div><br></div><div>Why did I use pushNil to allocate temps?  It was not a good choice; it means for example that to determine how many temps a block has one has to parse all the bytecodes and see where the stack pointer is at the end (since initial pushNils are ambiguous; an initial pushNil might be producing a parameter or result or initializing a temp).  But not using pushNil would have meant a more complex bytecode for closure creation plus another inst var in BlockClosure.  I made another similar misstep in not storing the method in a BlockClosure, hence preventing simple implementation of clean blocks (one needs to synthesize an outerContext also).  We live and learn.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br><div class="gmail_quote">On Sat, Apr 14, 2012 at 1:09 PM, Stéphane Ducasse <span dir="ltr">&lt;<a href="mailto:stephane.ducasse@inria.fr" target="_blank">stephane.ducasse@inria.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I&#39;m taking some times to go back the block closure chapter and I was wondering how I can get access to block temporaries<br>
<br>
[ |a | a :=2.  a]<br>
<br>
for example I tried<br>
<br>
[ |a | a :=2.  a]<br>
<br>
outerContext contextForLocalVariables tempAt: 1 and variations but none worked.<br>
<br>
Stef<br>
<br>
<br>
<br>
</blockquote></div><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>