Avoid using = on points
Exactly.
"=" is for numbers, strings and symbol names, and that's it.
(setq a '("a" "b" "c" 1 2.0))
("a" "b" "c" 1 2.0)
(setq b '("a" "b" "c" 1 2.0))
("a" "b" "c" 1 2.0)
Are these lists equal to each other? Certainly, they seem to be but ...
(= a b) -> nil
Each item may be tested T with "=",
(mapcar '= a b) -> (T T T T T)
because it is testing what it's designed to do: numbers and strings. But comparing lists with it is no good.
EQ will also "fail" the test:
(eq a b) -> nil
EQ is comparing bindings, which means that
a and
b need to be bound to the same thing in order to be found equal. In this case, each list was build separately and has nothing to do with each other internally. Binding variables to the same object will make them equal in the eyes of EQ:
(setq c a)
("a" "b" "c" 1 2.0)
(eq a c) -> T
Only EQUAL compares lists by their literal contents:
(equal a b) -> T
By the way, using "=" to compare the variables after they have been bound to the same list will return T, which can cause one to think that EQ and "=" are alike:
(= a c) -> T
But try using them on, say, entity names:
(setq e1 (entlast))
<Entity name: 7ef5ce90>
(setq e2 (entlast))
<Entity name: 7ef5ce90>
e1 and
e2 will be bound to the same physical object in memory, so EQ returns T:
(eq e1 e2) -> T
But "=" returns nil even though the objects are identical. It is not designed to handle those data types:
(= e1 e2) -> nil