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

John Cowan cowan at ccil.org
Thu Oct 26 23:55:52 EDT 2006


---
This message is a formal comment which was submitted to formal-comment at r6rs.org, following the requirements described at: http://www.r6rs.org/process.html
---
Submitter: John Cowan
Email address: cowan at ccil.org
Issue type: Defect
Priority: Minor
Component: Base library
Report version: 5.91
Summary:
The fact that (= +nan.0 +nan.0) is #f has unexpected knock-on effects
on eq? and eqv?.

In particular, (lambda (x) (eqv? x x) +nan.0) and its equivalent
(lambda (x) (eq? x x) +nan.0) are compelled to return #f by the
definitions of eqv? and eq?.  This is extremely counterintuitive,
and makes the suggestion that eq? compare pointers unusable: the
pointers must be checked to see if they happen to point to flonums
which happen to be NaNs.

I have two alternative proposals:

1) Allow eqv? and eq? to return either #t or #f if both arguments are NaNs.
2) Require eqv? to return #t if both arguments are NaNs.
   eq? would be permitted to return either #t or #f, as with all numbers.

-- 
I could dance with you till the cows            John Cowan
come home.  On second thought, I'd              http://www.ccil.org/~cowan
rather dance with the cows when you             cowan at ccil.org
came home.  --Rufus T. Firefly




More information about the r6rs-discuss mailing list