<div dir="ltr"><br><br><div class="gmail_quote">On Thu, Jul 31, 2008 at 3:54 PM, Ramon Leon <span dir="ltr">&lt;<a href="mailto:ramon.leon@allresnet.com">ramon.leon@allresnet.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="Wj3C7c"><br>
&gt; askoh wrote:<br>
&gt; &gt; | block |<br>
&gt; &gt; block := [:i | Transcript cr; show: i].<br>
&gt; &gt; 1 to: 10 do: [:i | block value: i+1]<br>
&gt; &gt;<br>
&gt; &gt; The above should print ten times. But it only prints the<br>
&gt; five even numbers.<br>
&gt; &gt; That is a bug isn&#39;t it?<br>
&gt; &gt;<br>
&gt; &gt; Aik-Siong Koh<br>
&gt; &gt;<br>
&gt; More of a &quot;known limitation&quot; than a bug... due to the fact<br>
&gt; that squeak<br>
&gt; does not have proper closures.<br>
&gt;<br>
&gt; try<br>
&gt;<br>
&gt; | block |<br>
&gt; block := [:j | Transcript cr; show: j].<br>
&gt; 1 to: 10 do: [:i | block value: i+1]<br>
&gt;<br>
&gt; Keith<br>
<br>
</div></div>I was going to say that, but why does it work using (1 to: 10) do: rather<br>
than 1 to: 10 do:, seems related to #to:do: being inlined?</blockquote><div><br></div><div>Yes. &nbsp;In the activation of to:do: there is a different counter. &nbsp;Look at the implementation of Number&gt;&gt;to:do:. &nbsp;So while both i&#39;s are still the same lvalue, i is not used by Number&gt;&gt;to:do: either to control the loop iterations or to to derive the values for the loop. &nbsp;Only when the loop is inlined does i become the loop control variable.</div>
<div><br></div><div>HTH</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div class="Wj3C7c">Ramon Leon<br>
<a href="http://onsmalltalk.com" target="_blank">http://onsmalltalk.com</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>