On Wed, 23 Dec 2009, Julian Fitzell wrote:
Funnily I just spent last week with John O'Keefe looking at non-VASt-compatible protocol that Seaside uses, comparing it across platforms, and pondering which pieces to include tests for in Grease and which to stop using in Seaside. (by the way, he was happy to add a whole bunch of "useful" protocol to their base image, which is great news). I need to write a summary of everything we came up with as well over the holidays, but in the meantime, here's what we came up with around sorting:
#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.
+1
#asSortedCollection is defined by ANSI on Collection and returns an instance of SortedCollection.
And this shouldn't be used for sorting.
#sort and #sort: -- Squeak/Pharo have it on ArrayedCollection, VW has it on SequenceableCollection, and VASt will now add it. This sorts the instance in place.
The problem here is that not all SequenceableCollections are sortable, for example instances of Interval can't be sorted. In squeak trunk ArrayedCollection and OrderedCollection understand both.
#sorted, #sorted: -- VW already has this. VA is adding it. Squeak/Pharo should add it, IMO, but we'll add it to Grease if not. It returns a sorted copy of SequenceableCollections and a sorted Array of all other collections.
+1, except for SequenceableCollection, see above
#sortBy: is silly, as you mention and not supported on any other platform. We're adding it to our lint rules as a "do not use" method.
+1
We didn't notice #asSortedArray but I think that's a terrible name -- the pattern with #as* methods is that the thing after the "as" should be a class. That behaviour could be easily achieved with "aCollection sorted asArray" or "aCollection asArray sort" if really needed.
+1, also note that in squeak/pharo #as* methods have semantic differences Levente
So that's what VASt/Seaside/Grease are doing... I encourage you to follow our lead. :)
Julian
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project