Subject: bug#9469: buffer-local variables seem to remember previous values

From: Helmut Eller <[email-masked]>
Date: Tue, 13 Sep 2011 22:42:34 +0200

* Drew Adams [2011-09-13 18:52] writes:

[...]
> The Lisp reader is kind of in the background of user awareness, so the
> question of where the Lisp object comes from can mistakenly be
> answered by thinking that it is `quote' that creates it based on the
> text/sexp that follows the '.  That, I think, is the gotcha that
> tripped up Le (and he's not alone).

Yes, that's crucial.  Beginners need to understand that read and eval
are separate and what the purpose of each is: read turns text into
s-expressions.  eval "executes" s-expressions; eval is described in
terms of s-expressions and not text.  Also that the reader is not the
only way to construct s-expressions for eval.

[...]
> Given that understanding, what can also be missing is that, depending
> on the Lisp, the Lisp reader might not create a _new_ list each time
> it encounters the sexp "(a b c)".  And in Emacs Lisp it in fact does
> not create a new list; it reuses a previously created list, if
> available.  (Is that always true for Elisp?  What about gc?).

I've never heard of a reader that does what you describe here.  The
reader creates a new list for "'foo" just as for "(quote foo)" or for
"(bar foo)".

(eq (read "'a") (read "'a")) returns nil; all the time.

Just like
(let ((sexp (read "('a 'a)")))
  (eq (car sexp) 
      (cadr sexp)))
is always nil.

The reader interns symbols but lists and vectors are freshly created
(ignoring the #1# syntax for now).  The compiler may coalesce constant
lists that are equal; but don't let us confuse the reader with the
compiler.

Helmut