<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"><<a href="mailto:Lou@keystone-software.com" target="_blank">Lou@keystone-software.com</a>></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'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>
<<a href="mailto:casey.obrien.r@gmail.com">casey.obrien.r@gmail.com</a>> wrote:<br>
<br>
>I didn't read your post clearly enough. Yep, that would seem odd. You may<br>
>have a bug there. I'm not sure why that happens. It looks like the outer<br>
>context isn't taking the assignment, but hanging onto the initial value it<br>
>receives from #value:.<br>
><br>
>I'm not totally sure we should expect to be able to do what you're trying<br>
>to do in modern Squeak. I haven't assigned to a block arg in a long time (I<br>
>keep allow block assignments off unless I'm loading old code.) I don't know<br>
>what the status is there. I run a relatively recent Cog VM on a 10.7.5 Mac<br>
>and I'm seeing the same behavior in Squeak 4.4.<br>
><br>
>When I switch to an old VM (3.8.18Beta3U) and run Squeak 3.0, your snippet<br>
>works as expected. I'm not sure if this is in the image or the VM yet, or<br>
>whether it's expected behavior or not with allowBlockArgumentAssignment<br>
>(Again, I usually turn it off.)<br>
><br>
>The main take away here is, don't do that:) as it's a back-compat feature<br>
>and it really ought to have a big sign on it that says DEPRECATED. If<br>
>you're trying to load some older code and running into this, it might be<br>
>better to actually rewrite it not to assign to block arguments in my<br>
>opinion (and maybe I'm nuts.)<br>
><br>
>Can you tell me what VM you're using?<br>
><br>
>Smalltalk vmVersion "this will tell us"<br>
><br>
>And also which version of Squeak?<br>
><br>
>SmalltalkImage current systemInformationString "ditto"<br>
><br>
>Also, what's the OS of the host system?<br>
><br>
><br>
><br>
>On Mon, Aug 5, 2013 at 1:44 AM, psea <<a href="mailto:denis.lukichev@gmail.com">denis.lukichev@gmail.com</a>> wrote:<br>
><br>
>> Hi Smalltalkers!<br>
>><br>
>> Here is a question I can't find answer with google.<br>
>> In short: Does block parameters and block local variables are the same<br>
>> thing<br>
>> (semantically) inside closure? It looks like it'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't work as intended:<br>
>><br>
>> a1 := makeAcc value: 10<br>
>> a1 value: 1 => 11<br>
>> a1 value: 1 => 11<br>
>> a1 value: 2 => 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 => 11<br>
>> a1 value: 1 => 12<br>
>> a1 value: 2 => 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:<br>
>> <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>
>><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>