Hi Rob,<br><br><div class="gmail_quote">On Sun, Mar 8, 2009 at 10:13 AM, Rob Rothwell <span dir="ltr">&lt;<a href="mailto:r.j.rothwell@gmail.com">r.j.rothwell@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;">
<div class="gmail_quote"><div class="im">On Sun, Mar 8, 2009 at 12:38 PM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">


multiply := Array new: 4.<br>
1 to: 4 do: [:i |<br>
        multiply at: i put: [:x | x * i].<br>
].<br>
<br>
And you would rightfully assume that this is equivalent to the version above, just more concise. But now try again:<br>
<br>
(multiply at: 3) value: 5.<br>
<br>
The answer will, surprisingly, not be 15 in current Squeak. </blockquote></div><div><br>You are right!  25, in fact...<br> </div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">

But with closures, the blocks would behave as expected. They are said to &quot;close over&quot; the state that the bound variables (i in this case) had at the time the block was created.</blockquote></div><div><br>So...VW does this &quot;right,&quot; I guess, since I get 15 in VW NC 7.6? <br>

<br></div><div class="im"><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
So basically, you can use blocks as you always have, but they will behave as you might have assumed they would.<br><font color="#888888">
</font></blockquote></div></div><br>So the recent VM work discussed handles this?  I will have to give that a try!<br><br>Thanks for the explanation!  The next question, of course, is WHY does it get 25 and not 15... ;)</blockquote>
<div><br></div><div>My blog goes into the excruciating details:</div><div><br></div><div>    <a href="http://www.mirandabanda.org/cogblog/2008/06/07/closures-part-i/">http://www.mirandabanda.org/cogblog/2008/06/07/closures-part-i/</a> </div>
<div><br></div><div>and the other posts starting with &quot;Closures&quot;</div><div><br></div><div>HTH</div><div><br></div><div>Eliot.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><font color="#888888"><br>
Rob<br>
</font><br><br>
<br></blockquote></div><br>