<div dir="ltr"><br><br><div class="gmail_quote">On Thu, Jul 31, 2008 at 3:32 PM, askoh <span dir="ltr">&lt;<a href="mailto:askoh@askoh.com">askoh@askoh.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
| block |<br>
block := [:i | Transcript cr; show: i].<br>
1 to: 10 do: [:i | block value: i+1]<br>
<br>
The above should print ten times. But it only prints the five even numbers.<br>
That is a bug isn&#39;t it?</blockquote><div><br></div><div>yes, but its ancient. &nbsp;It is to do with the implementation of blocks and specifically block temporaries. &nbsp;Both blocks bind to the same &quot;i&quot;. &nbsp;So when you evaluate</div>
<div>&nbsp;&nbsp; &nbsp;block value: i + 1</div><div>the 1 to: do:&#39;s i gets incremented.</div><div><br></div><div>Try this with my closure implementation (<a href="http://www.mirandabanda.org/cogblog/downloads/">http://www.mirandabanda.org/cogblog/downloads/</a>) and it is fixed.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Aik-Siong Koh<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Serious-bug-in-3.10-tp18764850p18764850.html" target="_blank">http://www.nabble.com/Serious-bug-in-3.10-tp18764850p18764850.html</a><br>
Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
<br>
</font></blockquote></div><br></div>