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