EQ Predicate

The predicate EQ tests for equality of pointer values inside the machine. It is faster than EQUAL, but less general in its applicability.

EQ always works for comparisons where at least one comparand is a symbol, since symbols are always unique structures in memory. Comparisons against constant symbols are usually done with EQ; EQL is like EQ, but also works for numbers.



(IF (EQ (CAR FORM) '+) (PRINT 'ADD))

In general, EQ does not work for numbers or for non-atomic s-expressions.


(EQ 'A 'A)          =   T
(EQ '(A) '(A))      =   NIL
(EQUAL '(A) '(A))   =   T
(EQ (+ 2 2) 4)      =   T ? (implementation
                             dependent)
(EQUAL (+ 2 2) 4)   =   T
(EQL (+ 2 2) 4)     =   T

Contents    Page-10    Prev    Next    Page+10    Index