[squeak-dev] Cuis problem with blocks

Juan Vuletich juan at jvuletich.org
Thu Jan 21 12:33:53 UTC 2010


Thanks, Nicolas. You're right. I did include the preference in Cuis. By 
default it is set not to allow assignment to block args. I recompiled 
the whole system this way, removing any block arg assgnment left. I see 
no reason to allow them, but the preference is there if someone needs it.

Cheers,
Juan Vuletich

Nicolas Cellier wrote:
> 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
> pre-closure world.
>
> Cheers
>
> Nicolas
>
> 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?
>>
>> Thanks,
>> Phil
>>
>>     




More information about the Squeak-dev mailing list