[squeak-dev] Cuis problem with blocks
nicolas.cellier.aka.nice at gmail.com
Thu Jan 21 07:18:56 UTC 2010
Writing to block arguments is considered bad practice.
In most Smalltalk (all?), you cannot write method arguments.
Since blocks are proper closures (introduced in Cuis 2.0) same rule
now apply to block arguments.
In squeak trunk, this behavior is driven by a Preferences, you can ask
Juan if he applied same policy in Cuis.
Anyway, [:sum :ea | sum := sum + ea] is completely useless since the
variable sum cease to exist once the block closure finish execution.
It has exactly same effect as [:sum :ea | sum + ea].
This pattern was the result of some bad understanding of block return
value and particularly the way inject:into: works, even in the
2010/1/21 Phil (list) <pbpublist at gmail.com>:
> I'm attempting to get some code running on Cuis 2.0 and am having a problem
> with some pretty simple blocks like:
> [:sum :ea | sum := sum + ea] value: 1 value: 2.
> resulting in an error:
> [:sum :ea | Cannot store into ->sum := sum + ea] value: 1 value: 2.
> However, this example works without a problem in both 3.10.2 as well as 3.7.
> Any idea what's going on?
More information about the Squeak-dev