The reason the standard says (eq? '(a) '(a))
is unspecified is because the implementation can choose to do common subexpression elimination on the parameters, which would transform it into something like this:
(let ((x '(a)))
(eq? x x))
In this case the implementation is allowed to return #t
. But notice that for (eq? (list 'a) (list 'a))
the implementation is required to return #f
, because list
always returns a fresh object and on distinct locations it must return #f
.