[LISPWORKS][Common Lisp HyperSpec (TM)] [Previous][Up][Next]


Function EQL

Syntax:

eql x y => generalized-boolean

Arguments and Values:

x---an object.

y---an object.

generalized-boolean---a generalized boolean.

Description:

The value of eql is true of two objects, x and y, in the folowing cases:

1. If x and y are eq.
2. If x and y are both numbers of the same type and the same value.
3. If they are both characters that represent the same character.

Otherwise the value of eql is false.

If an implementation supports positive and negative zeros as distinct values, then (eql 0.0 -0.0) returns false. Otherwise, when the syntax -0.0 is read it is interpreted as the value 0.0, and so (eql 0.0 -0.0) returns true.

Examples:

 (eql 'a 'b) =>  false
 (eql 'a 'a) =>  true
 (eql 3 3) =>  true
 (eql 3 3.0) =>  false
 (eql 3.0 3.0) =>  true
 (eql #c(3 -4) #c(3 -4)) =>  true
 (eql #c(3 -4.0) #c(3 -4)) =>  false
 (eql (cons 'a 'b) (cons 'a 'c)) =>  false
 (eql (cons 'a 'b) (cons 'a 'b)) =>  false
 (eql '(a . b) '(a . b))
=>  true
OR=>  false
 (progn (setq x (cons 'a 'b)) (eql x x)) =>  true
 (progn (setq x '(a . b)) (eql x x)) =>  true
 (eql #\A #\A) =>  true
 (eql "Foo" "Foo")
=>  true
OR=>  false
 (eql "Foo" (copy-seq "Foo")) =>  false
 (eql "FOO" "foo") =>  false

Normally (eql 1.0s0 1.0d0) is false, under the assumption that 1.0s0 and 1.0d0 are of distinct data types. However, implementations that do not provide four distinct floating-point formats are permitted to ``collapse'' the four formats into some smaller number of them; in such an implementation (eql 1.0s0 1.0d0) might be true.

Side Effects: None.

Affected By: None.

Exceptional Situations: None.

See Also:

eq, equal, equalp, =, char=

Notes:

eql is the same as eq, except that if the arguments are characters or numbers of the same type then their values are compared. Thus eql tells whether two objects are conceptually the same, whereas eq tells whether two objects are implementationally identical. It is for this reason that eql, not eq, is the default comparison predicate for operators that take sequences as arguments.

eql may not be true of two floats even when they represent the same value. = is used to compare mathematical values.

Two complex numbers are considered to be eql if their real parts are eql and their imaginary parts are eql. For example, (eql #C(4 5) #C(4 5)) is true and (eql #C(4 5) #C(4.0 5.0)) is false. Note that while (eql #C(5.0 0.0) 5.0) is false, (eql #C(5 0) 5) is true. In the case of (eql #C(5.0 0.0) 5.0) the two arguments are of different types, and so cannot satisfy eql. In the case of (eql #C(5 0) 5), #C(5 0) is not a complex number, but is automatically reduced to the integer 5.


[Starting Points][Contents][Index][Symbols][Glossary][Issues]
Copyright 1996-2005, LispWorks Ltd. All rights reserved.