chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] EQV? and NaN


From: John Cowan
Subject: Re: [Chicken-users] EQV? and NaN
Date: Tue, 12 Jul 2011 00:45:55 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

Felix scripsit:

> The fact that +NaN is a number and at the same time is not a number
> does not fit into what I consider common sense. It's most strikingly
> nonsensical. As if 4 equivalence procedures where not enough, we start
> to add special cases to increase confusion even more. Now it's a
> number ... and now it's not! Is it real? Is it rational?
>
> +NaN is merely a performance hack to keep tight numerical code branch
> free. To retroactivelsy give it some metaphysical meaning introduces
> countless inconsistencies into language implementations.

What I'm proposing is not so absurd as all that.

Two NaNs aren't numerically equal because they may not come from the
same source.  For example, the value of (sqrt 0.0) is no (real) number
at all, whereas the value of (/ 0.0 0.0) could be any real number.
Having two such NaNs compare = would create false positives.

But whan +nan.0 is used as a Scheme object like any other, it's
another story.  For example, if you (define h (make-hash-table)) and
then (hash-table-set! h +nan.0 32), and then ask for the value of
(hash-table-ref h +nan.0), Chicken will tell you there is no such entry
in h, because +nan.0) is not equal? (or eqv?) to any of the keys in h.
Yet the hash-table-size of h is 1.  That, I submit, is nonsensical.

-- 
Yes, chili in the eye is bad, but so is your    John Cowan
ear.  However, I would suggest you wash your    address@hidden
hands thoroughly before going to the toilet.    http://www.ccil.org/~cowan
        --gadicath



reply via email to

[Prev in Thread] Current Thread [Next in Thread]