[Seaside-dev] Re: [Seaside Commits] Seaside 3.0: Grease-Pharo-Core-lr.15.mcz

Julian Fitzell jfitzell at gmail.com
Wed Mar 31 10:24:34 UTC 2010


On Wed, Mar 31, 2010 at 9:42 AM, Lukas Renggli <renggli at gmail.com> wrote:
>> So why was the test failing?
>
>>>  ----- Method: SequenceableCollection>>sorted: (in category '*grease-pharo-core') -----
>>>  sorted: sortBlock
>>> +       ^ self sortBy: sortBlock!
>>> -       ^ (self sortBy: sortBlock) as: self species!
>
> #species of SortedCollection is SortedCollection. Sorting a
> SortedCollection with a non-default sortBlock, but then the collection
> is converted to a SortedCollection with a default sort block, what
> gives the default sorting.
>
> I don't know if it is correct to remove the #as: and what was its
> intention? It doesn't break any tests though, so I guess it is fine.
> Alternatively we could implement the method in SortedCollection like
> this.

I think the tests are not thorough enough then, though I thought I had
tests for the class of the returned object (maybe we removed them
because they were failing?). But it does seem like #sorted:, which
returns a copy, should be returning an instance of #species (certainly
this is necessary for classes like Interval, which has a species of
Array).

Certainly the current implementation of #sorted is inefficient and
suboptimal and could be improved on SortedCollection to simply "^ self
copy sortBlock: aBlock; yourself".

Julian


More information about the seaside-dev mailing list