[squeak-dev] asSortedCollection always copies?

Levente Uzonyi leves at elte.hu
Fri May 6 21:54:26 UTC 2011


On Fri, 6 May 2011, Ralph Boland wrote:

> I am using Squeak 10.2 and haven't checked 4.2 so apologies if this doesn't
> apply to 4.2.  I checked 4.1 though and the problem is in 4.1 also.
>
> Method asSet returns self for sets and method asArray returns self for arrays
> but asSortedCollection returns a copy of the sortedCollection for
> SortedCollections.
>
> This inconsistency constitutes a bug to my mind.
> Unless someone disagrees I will generate a bug report.
> Pointing out that the this is fixed in 4.2 constitutes disagreement.
> (If you fix the bug for 4.3 and then post that it is fixed saves me
> generating the bug report; of course you shouldn't do this).

I'd call it a design flaw. IMHO it's pretty hard to change, because some 
code may rely on copying. But it's on my todo list since the early days of 
the new community developement model.
For the note: #asOrderedCollection and #asCharacterSet are also creating 
copies no matter what the receiver is.

The case of #asSortedCollection has a simple solution: don't use it. 
There's 99.9% chance that you don't need a SortedCollection. If you 
want to sort a Collection, then use #sort, #sorted, #sort: or #sorted:.

I have a plan for fixing SortedCollection, but it has really-really low 
priority on my todo list, because we already have something better. :)


Levente

>
> Regards,
>
> Ralph Boland
>
>



More information about the Squeak-dev mailing list