[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] Proposed language for 'eqv?' applied to inexact real numbers
- To: Noah Lavine <noah.b.lavine@x>
- Subject: Re: [Scheme-reports] Proposed language for 'eqv?' applied to inexact real numbers
- From: Mark H Weaver <mhw@x>
- Date: Mon, 12 Nov 2012 12:34:02 -0500
- Cc: scheme-reports@x
- In-reply-to: <CA+U71=MviDMYuKEYo5+04rSLOdprpjjXa2Z7-BCN8YS7-j5pAg@mail.gmail.com> (Noah Lavine's message of "Mon, 12 Nov 2012 08:47:57 -0500")
- References: <firstname.lastname@example.org> <email@example.com> <CA+U71=MviDMYuKEYo5+04rSLOdprpjjXa2Z7-BCN8YS7-j5pAg@mail.gmail.com>
Noah Lavine <noah.b.lavine@x> writes:
> The 'eqv?' predicate on two elements of S must return #t if its
> arguments are the same member of S, and #f otherwise. Note that a
> single member of S may have different representations, but arithmetic
> operations are defined on the abstract set S and not on the
> The goal is basically to push parts of the definition of eqv? down to
> implementations, but do it in a structured way. This would require
> that (eqv? 1.0 1.0) => #t,
It is a mistake to try to ensure that (eqv? x y) => #true when x and y
represent the same numeric value in different representations. You are
trying to make 'eqv?' act like '=', and that is a fundamental error, and
a very common one.
Since we all agree that (eqv? 0 0.0) => #false, it is already not useful
as a numerical equality test, so please stop trying to make it one. It
will never do that job properly, and you will only destroy its ability
to do the one important job that it is good at.
'eqv?' has an entirely different purpose, and that is to determine
whether two objects are known to be operationally equivalent.
Admittedly, the precise definition of "operationally equivalent" is
difficult to formalize. Nonetheless that is the basic idea, and that
has _always_ been the case since it was first introduced in the RRRS.
The RRRS defined 'eqv?' on inexact numbers as follows (this is actually
from its definition of 'eq?', but 'eqv?' was defined as being the same
as 'eq?' for inexact numbers):
http://dspace.mit.edu/bitstream/handle/1721.1/5600/AIM-848.pdf (page 24)
"Returns #!true if obj1 is identical in all respects to obj2,
otherwise returns #!false. If there is any way at all that a user
can distinguish obj1 and obj2, then eq? will return #!false."
It is a shame that the R4RS and R5RS stopped explaining the concept
behind 'eqv?' that was so clearly explained in the RRRS and R3RS. The
result is that the current generation of Scheme hackers have apparently
forgotten what 'eqv?' is for.
Scheme-reports mailing list