[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in documentation for eq? ?
From: |
David Kastrup |
Subject: |
Re: Bug in documentation for eq? ? |
Date: |
Wed, 20 Jun 2012 13:32:49 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) |
Andy Wingo <address@hidden> writes:
> On Wed 20 Jun 2012 12:40, David Kastrup <address@hidden> writes:
>
>> Numbers and characters are not equal to any other object, but the
>> problem is they're not necessarily `eq?' to themselves either.
>> This is even so when the number comes directly from a variable,
>>
>> (let ((n (+ 2 3)))
>> (eq? n n)) => *unspecified*
>
> Note that this example is taken from R5RS section 6.1.
>
>> A variable reference can't really be anything except eq? to itself in
>> my opinion.
>
> Depends on inlining. Numbers are not considered to have identity, so
> they may be copied in some situations.
I can't see this being such a situation. The number 5 as such does not
have identity. But each individual instance of the number 5 is a Scheme
object, and Scheme objects have identity. That different instances of 5
may or may not compare eq?: no question about that. But the same?
That's just silly.
> In summary, I think the documentation is correct.
I think it is completely absurd. It would mean, for example, that
(memq x (list x))
is generally unspecified. It would mean that things like
(eq? (car x) (car x))
are generally unspecified even when x is a pair.
We have
scheme@(guile-user)> (eq? +nan.0 +nan.0)
$8 = #f
scheme@(guile-user)> (eqv? +nan.0 +nan.0)
$9 = #t
scheme@(guile-user)> (= +nan.0 +nan.0)
$10 = #f
scheme@(guile-user)> (let ((x +nan.0)) (eq? x x))
$11 = #t
scheme@(guile-user)> (let ((x +nan.0)) (eqv? x x))
$12 = #t
scheme@(guile-user)> (let ((x +nan.0)) (= x x))
$13 = #f
And that makes sense since eqv? is supposed to apply to a superset of
eq? while = is working on numerical values.
Which of the above would you consider unspecified?
--
David Kastrup
- Bug in documentation for eq? ?, David Kastrup, 2012/06/20
- Re: Bug in documentation for eq? ?, Andy Wingo, 2012/06/20
- Re: Bug in documentation for eq? ?,
David Kastrup <=
- Re: Bug in documentation for eq? ?, David Kastrup, 2012/06/20
- Re: Bug in documentation for eq? ?, Andy Wingo, 2012/06/20
- Re: Bug in documentation for eq? ?, Noah Lavine, 2012/06/20
- Re: Bug in documentation for eq? ?, Andy Wingo, 2012/06/20
- Re: Bug in documentation for eq? ?, David Kastrup, 2012/06/20
- Re: Bug in documentation for eq? ?, Andy Wingo, 2012/06/20
- Re: Bug in documentation for eq? ?, David Kastrup, 2012/06/20
- Re: Bug in documentation for eq? ?, David Kastrup, 2012/06/20
- Re: Bug in documentation for eq? ?, Andy Wingo, 2012/06/20
- Re: Bug in documentation for eq? ?, David Kastrup, 2012/06/20