Login  Register

Re: Comparison for SequencableCollection

Posted by webwarrior on Aug 03, 2015; 10:22pm
URL: https://forum.world.st/Comparison-for-SequencableCollection-tp4840704p4840859.html

We're drifting too much into philosophy here. Meaning of this, meaning
of that...

I'd argue there is no intrinsic meaning in statements such as "string A
is less than string B". But it is useful to have order defined on set of
words and character strings in general. Lexicographic order has some
useful properties and has been used in dictionaries for a long time.

Now nobody (OK, maybe I'm exaggerating a bit) questions whether strings
should have comparison and what ordering to use. We can easily
generalize this to all sequences with elements that can be compared -
and that's what designers of programming languages did. So it became
like de facto standard.

Note that default lexicographic ordering for strings is not always
desired - e.g. some file browsers have option of "numerical order"
(which accounts for numbers - "10" comes after "9" and so on). Still
it's not a reason to abandon default ordering.

On a side note: some functional programming languages with ADTs
(algebraic data types) automatically provide structural equality and
comparison for all ADTs, including user-defined, where it is possible.
And it's awesome, because it saves you from writing boilerplate code.
Again, you could say that there is no meaning in comparison of, say,
some n-ary trees of bools. But it has practical use: a datatype must
implement comparison to be used in sets and dictionaries that are based
on search trees.


On 03.08.2015 16:37, jtuchel [via Smalltalk] wrote:
>
> ...snip...
>