On Fri, 25 Dec 2009, Julian Fitzell wrote:
I'm pretty sure John was going to add #sort: at the level of SequenceableCollection. As I mentioned, it is implemented in terms of #at:put: and therefore errors reasonably on Interval.
Interval was just an example. Moving #sort: to SequenceableCollection requires some changes in it's subclasses: - ArrayedCollection (OK, nothing to do) - LinkedList (Link is too general, a sort algorithm has to make assumptions about the links, requires a new implementation of mergesort) - OrderedCollection (OK, easy to fix) - Interval (OK, can't be sorted. Some errors can be avioded though.) - SourceFileArray (who cares, it should be nuked anyway) - Heap (it raises an error in response to #at:put:, but it can be sorted...) - NSCollectionLimiter (?) So the question is: what to do with LinkedList and Heap? Levente
We might require a special implementation for SortedCollection, alright. I don't see why that would be a problem for them.
Julian
On Fri, Dec 25, 2009 at 1:08 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
ouf honor is safe :) So try to convince VA to do a better job than ANSI. because with sort: polymorph and sorted (suboptimal but ok) we can have a better solution
Stef
#sortBlock: is defined by ANSI on SortedCollection as an accessor and
an instance creation method. That's what it sounds like and shouldn't be implemented on non-sorted collections.
Why? what would be the reason not to use sortBlock: for others?
The intention is different. #sortBlock: tells a collection to maintain itself as sorted even after additions and deletions. This message is not appropriate for collections that do not have that ability.
#sortBlock: is not the best name for this functionality, but I think it's bad to use #sortBlock: with a different meaning.
I agree :) Now SortedCollection should understand sort too which uses sortBlock: My main concern is polymorphism between collection which are nearly the same!
#sortBlock: is an accessor for the sortBlock instance variable on SortedCollection. It makes no sense for a collection that doesn't have that instance variable to have that accessor.
did I say that? I do not think so. I'm not that idiot. No I say that SortedCollection should understand sort:
Ah, apologies - I misunderstood what you were saying (I was a little surprised that you would be arguing what I thought you were arguing :) ).
Julian
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project