[E-Lang] Operators #2: Comparison
Mark S. Miller
markm@caplet.com
Mon, 09 Apr 2001 10:21:43 -0700
At 06:10 AM Monday 4/9/01, Ralph Hartley wrote:
>Don't you need something like <> (x compareTo(y) belowZero()) || x
>compareTo(y) aboveZero())
The need for such a test comes up rarely enough that I'm happy to have
people have to write:
x < y || x > y
People reading this code can understand it without having to remember yet
another operator.
>I assume != is the negation of == so just as we need a separate <=>, we need
>(though, I conceed, not desperately) a "not equivalent" operator.
Likewise, I think it's fine that people have to write
!(x <=> y)
>>* On Java classes (and by extension perhaps, on declared E types, should we ever declare such things, as we probably will): x <= y means that x is a declared subtype of y. If y is a class, then x is y or a class that extends a class that's <= y. If y is an interface, then x is y or x is a class or interface that extends or implements a class that's <= y.
>
>You mean:
>
>If y is an interface, then x is y or x is a class or interface that extends
>or implements a class OR INTERFACE that's <= y.
Thanks. That says it much better. But, as you've seen, I've been convinced
to drop this use anyway.
>>[...] If the two lists are of equal length and everywhere pairwise equivalent, then the two lists are equivalent. (When the only disagreement is length, we generalize the answer from String. What is it?)
>
>The shorter string is < the longer.
Good. Agreed.
>Not defining it at all has its merits, but comparing the sets of keys isn't
>right anyway. The comparison of two maps should depend on the values, not
>just the keys. Here is a try at a definition: [...]
Wow. This is a very clever (and, I think, beautiful) extension of the idea
of lexicographic ordering. I'm not going to think about this yet.
Cheers,
--MarkM