GNU bug report logs -
#9469
buffer-local variables seem to remember previous values
Previous Next
Reported by: Le Wang <l26wang <at> gmail.com>
Date: Sat, 10 Sep 2011 17:12:01 UTC
Severity: normal
Tags: notabug
Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 9469 <at> debbugs.gnu.org (full text, mbox):
> > No, they should not be identical.
BTW, I should have said "It is not the case that they should be identical." Not
quite the same thing. There is no "should" here. AFAIK, most Lisps do not
prescribe the behavior in this regard - it is up to the implementation. But I'm
no expert on just what various Lisps define wrt this.
> > This is a classic Lisp gotcha.
> Thanks for the pointer, Drew.
>
> I was unable to google up any information regarding this as being a
> classic gotcha. Do you have any references?
No, I would have to google also. I said it's "classic", which probably really
means that I was bitten by the same gotcha many, many moon ago, and I learned my
lesson then, in discussion with people who knew Lisp well.
Well, a quick google of "lisp quote list" brings me to this:
http://stackoverflow.com/questions/134887/when-to-use-quote-in-lisp
Search that page for "DO NOT USE QUOTE TO CREATE LISTS THAT YOU WILL LATER
MODIFY". It says, "The spec allows the compiler to treat quoted lists as
constants." I guess it might be referring to the Common Lisp spec; dunno.
Scroll down further to the explanation by Matthias Benkard. He points out that
when you use (quote (a b c)) the list (a b c) is created (the first time) by the
Lisp loader or reader, not by `quote'. `quote' just returns that already
existing list. `quote' does not create new list structure (or new symbols or
new strings or...).
You can probably find other, similar explanations by googling.
The real lesson, I think, is what I said earlier, which works for all Lisps: Do
not expect `quote' to create new list structure.
> If this is in fact "by design", then the manual should definitely say
> so in the quoting section. Do I have to follow a different procedure
> to file a documentation bug?
I don't think the Elisp manual should say anything about it, but I'll let others
decide that.
The takeaway is, I think, that you should not depend on '(...) to create new
list structure each time it is evaluated. I suppose the manual could say that.
Or it could perhaps clarify that `quote' does not create new Lisp objects; it
just returns the object that is its argument, unevaluated. What can confuse
people is that the object already exists; it is provided by the reader (or the
loader).
I guess you could say that the reader treats list notation it encounters
similarly to what it does for symbol notation: if a symbol with the encountered
name already exists then it uses ("returns") that symbol. Otherwise, it first
creates a symbol with that name. IOW, the reader `intern's names it encounters.
Similarly, it handles list notation it encounters by either creating a new list
or returning an existing one.
Again, I'm no expert on this. Perhaps someone else can explain it better.
This bug report was last modified 13 years and 307 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.