On to Hydro
Mark S. Miller
markm@caplet.com
Fri, 18 Aug 2000 11:32:58 -0700
At 09:21 AM 8/18/00 , Dean Tribble wrote:
>a <= b primitive
>a >= b b <= a
>a == b a <= b && b <= a
>a != b !(a == b)
>
>For the operation 'mu' meaning not comparable (we didn't actually define such an operation :-)
>a mu b !(a <= b || b <= a)
>
>Finally, my vague reconstruction of the "strict" operations:
>a > b b <= a && !(a <= b)
>a < b a <= b && !(b <= a)
The above descriptions apply to E except that
* Dean's "==" corresponds to E's "<=>", since it means
"ordering-equivalence" rather than "computationally-equivalent", as in the
previous discussion of -0.0. (Tyler, both -0.0 and 0.0 must denote the same
real number, as there is only one real number they could denote: the one
called zero. Otherwise, what real number would you say -0.0 denotes?)
* E's primitive isn't "<=" or indeed any of the above, but rather
compareTo/1 (compareTo with one argument) and belowZero/0, atMostZero/0,
isZero/0, atLeastZero/0, and aboveZero/0. When two comparable entities, a
and b, are asked "a compareTo(b)", the result must be a "numeric" (ie, an
instance of a numeric data type). Specifically, if a is less than b,
compareTo/1 returns a negative numeric. If they are ordering-equivalent,
it returns a zero. If a is greater than b, it returns a positive numeric.
Otherwise, return a numeric that is none of these, ie, NaN. The expansions are
a < b expands to a compareTo(b) belowZero
a <= b expands to a compareTo(b) atMostZero
a <=> b expands to a compareTo(b) isZero
a >= b expands to a compareTo(b) atLeastZero
a > b expands to a compareTo(b) aboveZero
Why the funny terminology? NaN is, as it says, "not a number", so it cannot
be a member of the category "number". It denotes no mathematical number.
So I'll call the category "numerics", which I believe is standard usage.
Note that Java's terminology is simply confused: "Number" is the superclass
of Float and Double, each of which have an element which explicitly states
that it is "not a number".
Dean's "mu", which has no sugar in E, can be written as
a compareTo(b) isNaN
On strict weak orders (and therefore on total orders) compareTo/1 can return
integers rather than floating point numerics, since they won't ever return a
numeric that isn't less than, equal to, or greater than zero. (In the
current release of E, integers don't respond to isNaN/0, so the above mu code
won't work. In the next release, all integers respond to isNaN/0 with false.)
Cheers,
--MarkM