[r6rs-discuss] Re: [Formal] eq?/eqv? misbehave around NaNs

From: Marcin 'Qrczak' Kowalczyk <qrczak>
Date: Fri Nov 24 16:49:40 2006

Alan Watson <alan_at_alan-watson.org> writes:

> In practice, the main use of eqv? seems to be in making case useful
> for numbers and characters. Can you give examples of why requiring
> (eqv? +nan.0 +nan.0) to be true and (eqv? 1f0 1d0) to be false are
> useful?

Memoization (of pure functions).

> Can you come up with a description of eqv? that obtains the behaviour
> you want on singles and doubles without reference to their
> representation?

What does "singles" and "doubles" mean, if you are not allowed to
refer to the representation?

Values are eqv? if they are indistinguishable using a particular
subset of the language (which excludes eq? and eqv?, functions derived
from them like assq, except that certain "safe" and well-defined
subsets of their domains don't need to be excluded, e.g. eqv? on #t,
#f, exact integers, or eq? on conses).

In the case of doubt the subset is inclusive. "Distinguish" includes
the possibility of a well defined result in one case and undefined
behavior in the other. In general it is safe to err on the side of #f,
as long as every value is eqv? to itself.

eqv? must be an equivalence relation.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak_at_knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
Received on Fri Nov 24 2006 - 16:49:33 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC