On 02.08.2015 15:44, jtuchel [via Smalltalk] wrote:
I'd say it is questonable if SequenceableCollections should be comparable by default.
is (a b c) equal or lower than (b a c) ? Doesn't this depend heavily on what is in the Collection and what the meaning of the Sequence of two Collections is?
(a b c) = (b a c) if a = b (a b c) < (b a c) if a < b The semantics are well defined. Of course, it depends on what's in collection! That's the point - we compare collections by their content. If some elements are not comparable, we'll get DoesNotUnderstand - expected behavior when comparing non-comparable objects. It's the same story as with equality.
So I'd say there is not much use in putting comparisons into the base class library, because there is a ton of assumptions about the Collections in whatever implementation one can imagine. I would assume that this is the job of some business object that holds objects in a SequenceableCollection. Don't you think?
There is only one assumption - that elements of the first collection are comparable to the elements of the second collection. And I think that we shouldn't multiply entities beyond necessity by creating a class when using simple datastructure would be sufficient.
The fact that other languages provide such an implementation doesn't mean much to me, to be honest. I choose a SequencableCollection in order to keep objects in a certain order, nothing more, nothing less.
That's why we have methods such as polynomialEval: and asDigitsToPower:do: (and I'm not talking about extension methods) ?
I think it is important to not get "overridden" by the fact that something is extremely easy to do in Smalltalk. We can easily make bad mistakes, just because we can.
Just my 2 cents
Joachim
Am 02.08.15 um 14:11 schrieb webwarrior:
I was surprised when discovered that in Pharo comparison is not defined for lists, arrays and similar datastructures.
Because in almost every programming language (F#, Python, Javascript just to name few) you can compare lists, arrays, etc. By convention, the ordering is lexicographical, just like in strings.
It took little time to add needed methods to SequencableCollection, but I think its better to have them in core library (core image, or how do you call it?).
-- View this message in context: http://forum.world.st/Comparison-for-SequencableCollection-tp4840704.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
-- View this message in context: http://forum.world.st/Comparison-for-SequencableCollection-tp4840704p4840708... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.