Subject: Re: (eql x y) = T and (equal x y) = NIL
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 11 Feb 2009 06:31:42 -0600
Newsgroups: comp.lang.lisp
Message-ID: <1LydnWAhHe6zWA_UnZ2dnUVZ_qvinZ2d@speakeasy.net>
Pascal J. Bourguignon <pjb@informatimago.com> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) writes:
| > Pascal J. Bourguignon <pjb@informatimago.com> wrote:
| > +---------------
| > | Coarsely,
| > | EQL is the identity,
| > | EQUAL is the shallow structural equality,
| > | EQUALP is the deep structural equality.
| > +---------------
| >
| > Slightly less coarsely:
| >
| > EQ is object identity.
| > EQL is "sameness" (EQ plus "same" type/value characters & numbers).
| 
| I don't agree.
| 
| EQ compares _representation_ identity.
| EQL compares object identity.
| 
| (EQ 1 1) --> NIL   means that the same object, the integer 1, may have
| two different instances of its representation.  But there is only one
| object, the integer 1.
+---------------

I likewise beg to differ:

    > (eq 536870912 536870912)

    NIL
    > (eql 536870912 536870912)

    T
    > 

Clearly, here 536870912 and 536870912 are *different* objects!
But they are the same type (INTEGER) and value as numbers,
therefore EQL.

+---------------
| Duplicating object represenations is an optimization allowed, that
| implemetentation can easily do on immutable objects of size smaller
| than that of a pointer.  But in all cases, it's always the same single
| object, with its single identity.
+---------------

I think you have this backwards. Rather, it is the case that
*different* objects (not EQ) may be the "same" under EQL.
The two object instances above of the *value* 536870912
[READ at different times and allocted different locations
in memory] are the "same" under EQL... because EQL is defined
that way (clause #2 in CLHS "Function EQL").


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607