[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Scheme-reports] Formal Comment: R7RS 'eqv?' cannot be used for reliable memoization

Formal Comment

Submitter's name: Mark H Weaver
Submitter's email: mhw@x
Relevant draft: R7RS draft 7

Type: defect
Priority: major
Relevant section of draft: Equivalence predicates

Summary: 'eqv?' cannot be used for reliable memoization

The definition of 'eqv?' requires that (eqv? -0.0 +0.0) => #true when
the arguments are inexact real numbers not conforming to IEEE 754-2008,
even if -0.0 and +0.0 are not operationally equivalent.

This will cause eqv?-based memoized numerical procedures with a branch
cut on the real or imaginary axes to sometimes return incorrect results.
For example, if a memoized reciprocal procedure is first evaluated at
-0.0 (returning and memoizing -inf.0), and then later evaluated at +0.0,
it will return -inf.0, which is incorrect.

Why is this important, when almost all implementations that support
signed zeroes also conform to IEEE 754-2008?

GNU MPFR is a popular and efficient arbitrary-precision arithmetic
library that is likely to be supported by some implementations in the
future.  Although it supports signed zeroes, its does not support
gradual underflow, and thus does not conform to IEEE 754-2008.
Therefore R7RS requires that (eqv? -0.0 +0.0) => #true when the
arguments are represented using MPFR, thus making reliable memoization
impractical using R7RS.

The minimum requirement for reliable memoization is that 'eqv?' must
return #false when its arguments are not operationally equivalent.  As
currently written, R7RS will be the first Scheme standard to violate
this requirement for the numbers discussed in the standard.


Scheme-reports mailing list