Lisp has taught us that there are several kinds of equality of
objects. In C++ the == operator can only express one kind of
equality. Also without void* casting it can not be applied to
any two objects dynamically.
The == operator in Lpp can be applied to any two Lpp objects
dynamically and means the same as the eq function of Common
Lisp. However an eq function is still supplied so that an
eq function object can be passed to some functions that take an
optional predicate function argument. Also note that eq as
opposed to == is a true Lpp predicate in that it returns either
t or nil.
| eq x y | Function |
eq returns t if x is the same object as y and
nil otherwise.
| eql x y | Function |
eql is the same as eq except that if x and
y are Characters or Numbers of the same type
their values are compared.
| equal x y | Function |
equal returns t if x and y are
structurally similar (isomorphic) objects and nil otherwise.
Roughly speaking, t means that x and y print the
same way.
| equalp x y | Function |
equalp returns t if x and y are are
equal; if they are characters and are eql ignoring
alphabetic case; if they are numbers and have the same numerical
value, even if they are of different types; or if they have components
that are all equalp.
Objects that have components are equalp if they are of the same
type and corresponding components are equalp. This test is
implemented in a recursive manner and may fail to terminate for
circular structures. For conses, equalp is defined recursively
as the two car's being equalp and the two cdr's being
equalp.
Here are some example of all these equality predicates
eq(L(23), L(23)) => nil
eql(L(23), L(23)) => t
equal(L(23), L(23)) => t
eq(L('a'), L('a')) => t
eql(L('a'), L('a')) => t
equal(L('a'), L('A')) => nil
equalp(L('a'), L('A')) => t
eq(S(foo), S(foo)) => t
eql(S(foo), S(foo)) => t
equal(S(foo), S(foo)) => t
equal(S(foo), S(Foo)) => nil
equalp(S(foo), S(Foo)) => nil
eql(L("foo"), L("foo")) => nil
equal(L("foo"), L("foo")) => t
equal(L("foo"), L("Foo")) => nil
equalp(L("foo"), L("Foo")) => t
equalp(S(foo), L("foo")) => nil