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

From: John Cowan <cowan>
Date: Sat Oct 28 03:49:51 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
Received on Thu Oct 26 2006 - 23:55:52 UTC

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