[squeak-dev] The Inbox: Kernel-cmm.464.mcz

Joachim Geidel joachim.geidel at onlinehome.de
Sun Jun 20 09:21:26 UTC 2010

Am 19.06.10 22:00 schrieb Bert Freudenberg:
>> Item was added:
>> + ----- Method: Object>>asArray (in category 'converting') -----
>> + asArray
>> + 
>> +  ^ Array with: self
>> + 
>> + !
> Uh oh. Why not write {object} at the sending site?
> - Bert -


I don't like this. It has a completely different semantics than the existing
#asArray methods for Collections which is "Answer an Array with all of my
elements". The new method is "Answer an Array containing myself". If the
receiver is a Collection and you want this new semantics, one has to write
"Array with: self" again. That's not polymorphism IMHO. And it's possible to
introduce bugs in situations where the receiver of #asArray can be either a
Collection or another kind of object because it's not clear if you expect
the result to be an Array containing the receiver in all cases or not. Also,
this may cover bugs where one does not expect non-Collections to be a
receiver of #asArray - it would just continue to work where it shouldn't.

Does the ANSI Smalltalk standard say anything about #asArray?

Joachim Geidel

More information about the Squeak-dev mailing list