From: =?ISO-8859-15?Q?Andr=E9_Thieme?=
Subject: clisp: = and eql
Date: 
Message-ID: <d5j39p$t09$1@ulric.tng.de>
The hyperspec says:

"= differs from eql in that (= 0.0 -0.0) is always true, because = 
compares the mathematical values of its operands, whereas eql compares 
the representational values, so to speak."
http://www.lispworks.com/documentation/HyperSpec/Body/f_eq_sle.htm


I tried this in CLisp:
CL-USER> (= 0.0 -0.0)
T
CL-USER> (eql 0.0 -0.0)
T

I don't see how = and EQL differ. Is this an error in the hyperspec? In 
CLisp? In my brain?
What does your Lisp (other than CLisp) do in this situation?


Andr�
--

From: Frank Buss
Subject: Re: clisp: = and eql
Date: 
Message-ID: <d5j4la$2el$1@newsreader3.netcologne.de>
=?ISO-8859-15?Q?Andr=E9_Thieme?= <address.good.until.2005.may.16
@justmail.de> wrote:

> I tried this in CLisp:
> CL-USER> (= 0.0 -0.0)
> T
> CL-USER> (eql 0.0 -0.0)
> T
> 
> I don't see how = and EQL differ. Is this an error in the hyperspec? In 
> CLisp? In my brain?
> What does your Lisp (other than CLisp) do in this situation?

sometimes the hyperspec is difficult to understand, but looks like a bug in 
CLisp. In LispWorks on Windows:

CL-USER 1 > (= 0.0 -0.0)
T

CL-USER 2 > (eql 0.0 -0.0)
NIL

CL-USER 3 > 

and CMUCL on Linux:

* (= 0.0 -0.0)

T
* (eql 0.0 -0.0)

NIL

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: Juho Snellman
Subject: Re: clisp: = and eql
Date: 
Message-ID: <slrnd7q5r7.tjq.jsnell@sbz-31.cs.Helsinki.FI>
<······························@justmail.de> wrote:
> The hyperspec says:
> 
> "= differs from eql in that (= 0.0 -0.0) is always true, because = 
> compares the mathematical values of its operands, whereas eql compares 
> the representational values, so to speak."
> http://www.lispworks.com/documentation/HyperSpec/Body/f_eq_sle.htm
[...]
> I don't see how = and EQL differ. Is this an error in the hyperspec? In 
> CLisp? In my brain?

Implementations don't need to support a negative zero.

<http://www.lisp.org/HyperSpec/Body/syscla_float.html>

: In addition, there is a floating-point zero; depending on the
: implementation, there can also be a `minus zero''. If there is no
: minus zero, then 0.0 and -0.0 are both interpreted as simply a
: floating-point zero. (= 0.0 -0.0) is always true. If there is a minus
: zero, (eql -0.0 0.0) is false, otherwise it is true.

-- 
Juho Snellman
"Premature profiling is the root of all evil."
From: =?ISO-8859-15?Q?Andr=E9_Thieme?=
Subject: Re: clisp: = and eql
Date: 
Message-ID: <d5j581$up1$1@ulric.tng.de>
Juho Snellman schrieb:
> <······························@justmail.de> wrote:
> 
>>The hyperspec says:
>>
>>"= differs from eql in that (= 0.0 -0.0) is always true, because = 
>>compares the mathematical values of its operands, whereas eql compares 
>>the representational values, so to speak."
>>http://www.lispworks.com/documentation/HyperSpec/Body/f_eq_sle.htm
> 
> [...]
> 
>>I don't see how = and EQL differ. Is this an error in the hyperspec? In 
>>CLisp? In my brain?
> 
> 
> Implementations don't need to support a negative zero.
> 
> <http://www.lisp.org/HyperSpec/Body/syscla_float.html>
> 
> : In addition, there is a floating-point zero; depending on the
> : implementation, there can also be a `minus zero''. If there is no
> : minus zero, then 0.0 and -0.0 are both interpreted as simply a
> : floating-point zero. (= 0.0 -0.0) is always true. If there is a minus
> : zero, (eql -0.0 0.0) is false, otherwise it is true.

In this case the differences I see between eql and = are:
= only compares numbers and takes one and more arguments
while EQL compares all kind of objects and takes exactly two arguments.


Andr�
--
From: Juho Snellman
Subject: Re: clisp: = and eql
Date: 
Message-ID: <slrnd7q7mg.tjq.jsnell@sbz-31.cs.Helsinki.FI>
<······························@justmail.de> wrote:
> In this case the differences I see between eql and = are:
>= only compares numbers and takes one and more arguments
> while EQL compares all kind of objects and takes exactly two arguments.

Sorry, I didn't realize your original question wasn't just about
comparisons involving negative zero. = and EQ do fundamentally
different kinds of comparisons. Try for example:

(eq 1.0 1)
(= 1.0 1)

(eq #C(1 1) #C(1 1))
(= #C(1 1) #C(1 1))

-- 
Juho Snellman
"Premature profiling is the root of all evil."
From: Juho Snellman
Subject: Re: clisp: = and eql
Date: 
Message-ID: <slrnd7q8gj.tjq.jsnell@sbz-31.cs.Helsinki.FI>
[ Sorry if you see something resemblings this message twice. I wrote
  an incorrect reply, and cancelled it immediately. But who knows
  whether the cancellation actually propagates. ]

<······························@justmail.de> wrote:
> In this case the differences I see between eql and = are:
>= only compares numbers and takes one and more arguments
> while EQL compares all kind of objects and takes exactly two arguments.

Sorry, I thought you were asking just about the properties of negative
zeroes. = and EQL do different kinds of comparisons. Try for example:

(= 1.0 1)
(eql 1.0 1)

<······························@justmail.de> wrote:
> However, I don't see the differences between EQ and EQL in CLisp then.

Try:

(eq #C(1 1) #C(1 1))
(eql #C(1 1) #C(1 1))

And then read the CLHS pages for EQ and EQL. (Note especially that the
above two expressions may evaluate to different values, but are not
required to).

-- 
Juho Snellman
"Premature profiling is the root of all evil."
From: =?ISO-8859-15?Q?Andr=E9_Thieme?=
Subject: Re: clisp: = and eql
Date: 
Message-ID: <d5j5am$up1$2@ulric.tng.de>
Andr� Thieme schrieb:

> In this case the differences I see between eql and = are:
> = only compares numbers and takes one and more arguments
> while EQL compares all kind of objects and takes exactly two arguments.

However, I don't see the differences between EQ and EQL in CLisp then.


Andr�
--
From: Harald Hanche-Olsen
Subject: Re: clisp: = and eql
Date: 
Message-ID: <pcoacn6lpqh.fsf@shuttle.math.ntnu.no>
+ Andr� Thieme   <······························@justmail.de>:

| However, I don't see the differences between EQ and EQL in CLisp then.

I don't use CLisp, but in general (eq a b) implies (eql a b), but the
converse need not hold:  Two numbers that are of the same type and the
same value are EQL but not necessarily EQ.  You're most likely to see
this with bignums.  For instance, if a is a bignum then

  (eq a (* 2 (/ a 2)))

is quite likely to return nil.  For example,

(let ((a 98717987234968652983475091)) (eq a (* 2 (/ a 2))))

returns nil in cmucl, but t in sbcl.  Most likely because sbcl
compiles everything ... at least, cmucl too returns t if you compile
the above code and run it.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
  than thinking does: but it deprives us of whatever chance there is
  of getting closer to the truth.  -- C.P. Snow
From: Pascal Bourguignon
Subject: Re: clisp: = and eql
Date: 
Message-ID: <87ekcixvzq.fsf@thalassa.informatimago.com>
Andr� Thieme <······························@justmail.de> writes:

> Andr� Thieme schrieb:
>
>> In this case the differences I see between eql and = are:
>> = only compares numbers and takes one and more arguments
>> while EQL compares all kind of objects and takes exactly two arguments.
>
> However, I don't see the differences between EQ and EQL in CLisp then.

For fixnums and short-floats, there's no difference.  But for bigger
numbers, there may be a difference:


[272]> (eq 1 1)
T
[273]> (eq 1e12 (* 1e6 1e6))
NIL
[274]> (eq 1e12 1e12)
NIL


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This is a signature virus.  Add me to your signature and help me to live
From: GP lisper
Subject: Re: clisp: = and eql
Date: 
Message-ID: <1115793633.874653c5a7bc78487d660c3f536454e5@teranews>
On Sat, 07 May 2005 21:01:38 +0200, <······························@justmail.de> wrote:
> CL-USER> (= 0.0 -0.0)
> T
> CL-USER> (eql 0.0 -0.0)
> T
>
> What does your Lisp (other than CLisp) do in this situation?


; Loading #P"/etc/cmucl-init.lisp".
CMU Common Lisp Snapshot 2005-04, running on phoenix
With core: /usr/local/lib/cmucl-19a-0504/lib/lisp.core
Dumped on: Fri, 2005-04-15 14:32:11-07:00 on phoenix
See <http://www.cons.org/cmucl/> for support information.
Loaded subsystems:
    Python 1.1, target Intel x86
    CLOS based on Gerd's PCL 2004/04/14 03:32:47
    CLX X Library MIT R5.02
    Gray Streams Protocol Support
    Simple Streams
CL-USER> (= 0.0 -0.0)

T
CL-USER> (eql 0.0 -0.0)

NIL
CL-USER> *features*

(:CMU-HOOKS-REQUIRE :ASDF :MK-DEFSYSTEM :SIMPLE-STREAMS :GRAY-STREAMS
 :CLX-MIT-R5 :CLX-MIT-R4 :XLIB :CLX :CLX-LITTLE-ENDIAN :GERDS-PCL
 :PCL-STRUCTURES :PORTABLE-COMMONLOOPS :PCL :CMU19 :CMU19A :PYTHON
 :CONSERVATIVE-FLOAT-TYPE :MODULAR-ARITH :MP :X86 :LINKAGE-TABLE
 :RELATIVE-PACKAGE-NAMES :LINUX :GLIBC2 :UNIX :RANDOM-MT19937 :GENCGC :PENTIUM
 :I486 :HASH-NEW :HEAP-OVERFLOW-CHECK :STACK-CHECKING :COMMON :COMMON-LISP
 :ANSI-CL :IEEE-FLOATING-POINT :CMU)
CL-USER> 


-- 
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.