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

Igor Stasenko siguctua at gmail.com
Sun Jun 20 09:50:51 UTC 2010


On 20 June 2010 12:21, Joachim Geidel <joachim.geidel at onlinehome.de> wrote:
> 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 -
>
> +1.
>
> 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?
>

+1.

#asArray for non-collection types is ambiguous.

> Joachim Geidel
>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list