<div dir="ltr">I didn&#39;t read your post clearly enough. Yep, that would seem odd. You may have a bug there. I&#39;m not sure why that happens. It looks like the outer context isn&#39;t taking the assignment, but hanging onto the initial value it receives from #value:. <div>
<div><br></div><div style>I&#39;m not totally sure we should expect to be able to do what you&#39;re trying to do in modern Squeak. I haven&#39;t assigned to a block arg in a long time (I keep allow block assignments off unless I&#39;m loading old code.) I don&#39;t know what the status is there. I run a relatively recent Cog VM on a 10.7.5 Mac and I&#39;m seeing the same behavior in Squeak 4.4.</div>
<div style><br></div><div style>When I switch to an old VM (3.8.18Beta3U) and run Squeak 3.0, your snippet works as expected. I&#39;m not sure if this is in the image or the VM yet, or whether it&#39;s expected behavior or not with allowBlockArgumentAssignment (Again, I usually turn it off.)</div>
<div><br></div><div style>The main take away here is, don&#39;t do that:) as it&#39;s a back-compat feature and it really ought to have a big sign on it that says DEPRECATED. If you&#39;re trying to load some older code and running into this, it might be better to actually rewrite it not to assign to block arguments in my opinion (and maybe I&#39;m nuts.)</div>
<div style><br></div><div style>Can you tell me what VM you&#39;re using?</div><div style><br></div><div style>Smalltalk vmVersion &quot;this will tell us&quot;</div><div style><br></div><div style>And also which version of Squeak?</div>
<div style><br></div><div style>SmalltalkImage current systemInformationString &quot;ditto&quot;<br></div><div style><br></div></div><div style>Also, what&#39;s the OS of the host system?</div><div style><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Aug 5, 2013 at 1:44 AM, psea <span dir="ltr">&lt;<a href="mailto:denis.lukichev@gmail.com" target="_blank">denis.lukichev@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">
Hi Smalltalkers!<br>
<br>
Here is a question I can&#39;t find answer with google.<br>
In short: Does block parameters and block local variables are the same thing<br>
(semantically) inside closure? It looks like it&#39;s not. Below the<br>
explanation.<br>
<br>
===================<br>
Here is the accumulator function (first attempt):<br>
<br>
makeAcc := [ :acc |<br>
        [:n | acc:=acc+n. acc]]<br>
<br>
It turns out it doesn&#39;t work as intended:<br>
<br>
a1 := makeAcc value: 10<br>
a1 value: 1 =&gt; 11<br>
a1 value: 1 =&gt; 11<br>
a1 value: 2 =&gt; 12<br>
<br>
====================<br>
Here is the second attempt:<br>
<br>
makeAcc := [ :acc |<br>
        | total |<br>
        total:=acc.<br>
        [:n | total:=total+n. total]]<br>
<br>
And it does work as intended:<br>
<br>
a1 := makeAcc value: 10<br>
a1 value: 1 =&gt; 11<br>
a1 value: 1 =&gt; 12<br>
a1 value: 2 =&gt; 14<br>
<br>
So if we use the local variable to store accumulator it works as it should<br>
and remembers the value between function (block) calls. But if we use block<br>
parameter to store the value of accumulator it does not remembers the value<br>
between calls.<br>
Why is it so?<br>
<br>
P.S. Sorry for my English. I do all my best.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://forum.world.st/Modify-block-closure-parameters-tp4702118.html" target="_blank">http://forum.world.st/Modify-block-closure-parameters-tp4702118.html</a><br>
Sent from the Squeak - Beginners mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Casey Ransberger
</div>