GNU Emacs Lisp Reference Manual, 2.8 Equality Predicates:
Comparing circular lists may therefore cause deep recursion that leads to an error, and this may result in counterintuitive behavior such as
(equal a b)returning
(equal b a)signals an error.
I've found a case:
ELISP> (setq a '#1=(t . #1#) b `(t t . ,a)) ELISP> (equal b a) t ELISP> (equal a b) *** Eval error *** List contains a loop: #1=(t . #1#) ELISP>
Does Elisp test
eq first when testing
If so, I don't think
(equal a b) will signal an error.
a: t --- ^ | | | ---- b: t -> t -> t --- ^ | This loop is `a`. | | ----
when testing whether
bare not the same obj (i.e. not
- so test their first element, and
t; then test their CDRs
a's CDR and
b's CDR are not the same obj
- so test CDRs' first element, and
t; then test CDRs' CDRs
so I think
(equal a b) should return
Where is my mistake?