[MLton] ML/Lisp/Scheme, =, eq?, eqv?, equal?
Bradley Lucier
lucier@math.purdue.edu
Mon, 23 Feb 2004 16:27:58 -0500
This is an ML semantics question, so not exactly about implementing
MLton, but perhaps you can help me out here.
Over in the Scheme world there's a new administrative structure to
extend Scheme and possibly come up with R6RS. Marc Feeley, the
editor-in-chief of this effort, asked me to contribute some changes to
the Scheme standard that might make it more compatible with IEEE [78]54
arithmetic.
No problem, I thought, just divorce = from eq?, eqv?, and equal? (with
numerical = meaning what it means in IEEE arithmetic) and define eqv?
on IEEE numbers by
> 6.1 Equivalence predicates
>
> <Replace the parts about numbers with what I've written here. BTW,
> since each of these subclauses are supposed to be complete sentences
> (notice the periods ending them), they should each begin with capital
> letters.>
>
> The eqv? procedure returns #t if:
>
> * obj1 and obj2 are both IEEE 754/854 format numbers, and obj1 and
> obj2 have
> the same base, sign, number of exponent digits, exponent bias, biased
> exponent,
> number of significand digits, and significand.
>
> * obj1 and obj2 are both exact numbers and are numerically equal (see
> =, section 6.2).
>
> The eqv? procedure returns #f if:
>
> * one of obj1 and obj2 is an exact number but the other is an inexact
> number.
>
> * obj1 and obj2 are both IEEE 754/854 format numbers, and the base,
> sign,
> number of exponent digits, exponent bias, biased exponent, number of
> significand
> digits, or significand of obj1 and obj2 differ.
>
> * obj1 and obj2 are exact numbers for which the = procedure returns
> #f.
>
> Note: This section does not state under which conditions eqv? returns
> #t or #f
> for inexact numbers that are not in IEEE 754/854 format. We recommend
> that
> numbers not in IEEE 754/854 format for which a base, sign, number of
> exponent
> digits, exponent bias, biased exponent, number of significand digits,
> and
> significand can be defined follow the same rules as above.
I'm trying not to be a cowboy language designer, so I looked up ML's
version of Real, and found at
http://www.standardml.org/Basis/real.html#Real:STR:SPEC
that basically ML equality (whatever that means, is there a precise
Lisp equivalent?) does not apply to Reals; at least that's how I
understand the phrase "real is not an equality type".
I think the ML folks are bright guys and gals, so I'm disturbed. Why
not? What's wrong with the definition I gave above?
Brad