Arrays / collections with literal syntax - fixed size?

nice ncellier at ifrance.com
Sun Jan 6 15:33:43 UTC 2008


Right.

It's the fact that #(..) is a literal.
And modifying a literal is a bad practice, whatever the language.

However, { } is NOT a literal.
I hope the question raised by Sophie has been in the mind of whoever 
introduced this extension: why favor a specific Collection subclass in 
this case?
Well, the answer might be to maintain Smalltalk Core at a minimum. Since 
Array already are necessary for the literal form...

Nicolas

Alexander Lazarevic' wrote:
> Randal L. Schwartz schrieb:
>> The intent of an array is that it's readonly ("immutable").
>>   
> ?
> 
> So why does "#(1 2 3) at: 1 put: 5; yourself" evaluate to "#(5 2 3)" ?
> 
> Instances of Array have fixed sizes, yes. But I would not say that makes
> them readonly.
> 
> This works in Squeak too:
> 'Boy' at: 1 put: $T evaluates to 'Toy'
> 
> It won't work in (latest versions of) VisualWorks, where you have
> immutable literal strings.
>> And this belongs on -beginners, not -dev.
>>   
> I don't think so.
> 
> Alex
> 
> 




More information about the Squeak-dev mailing list