From: "Drew Adams" <drew.adams@oracle.com>
To: "'Le Wang'" <l26wang@gmail.com>
Cc: 9469@debbugs.gnu.org
Subject: bug#9469: buffer-local variables seem to remember previous values
Date: Sun, 11 Sep 2011 10:56:29 -0700 [thread overview]
Message-ID: <95CFAF98BEBE4DFAB885B85F02126C57@us.oracle.com> (raw)
In-Reply-To: <CAM=K+iqwi78pr3HXCw_gZjJ3U6Yu8vdy_zG7gT_289NTykc18Q@mail.gmail.com>
> > 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.
next prev parent reply other threads:[~2011-09-11 17:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 17:07 bug#9469: buffer-local variables seem to remember previous values Le Wang
2011-09-10 17:44 ` Drew Adams
2011-09-11 16:57 ` Le Wang
2011-09-11 17:56 ` Drew Adams [this message]
2011-09-11 18:08 ` Andreas Schwab
2011-09-11 18:49 ` Le Wang
2011-09-11 18:54 ` Lars Magne Ingebrigtsen
2011-09-11 19:18 ` Le Wang
2011-09-11 19:54 ` Lars Magne Ingebrigtsen
2011-09-12 4:39 ` Le Wang
2011-09-12 7:57 ` Andreas Schwab
2011-09-12 8:23 ` Le Wang
2011-09-12 8:35 ` Andreas Schwab
2011-09-12 14:30 ` Drew Adams
2011-09-12 15:06 ` Le Wang
2011-09-13 12:54 ` Stefan Monnier
2011-09-13 13:12 ` Le Wang
2011-09-13 15:00 ` Helmut Eller
2011-09-13 18:02 ` Johan Bockgård
2011-09-13 18:52 ` Drew Adams
2011-09-13 20:42 ` Helmut Eller
2011-09-15 18:14 ` Le Wang
2011-09-11 19:37 ` Helmut Eller
2011-09-11 19:46 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=95CFAF98BEBE4DFAB885B85F02126C57@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=9469@debbugs.gnu.org \
--cc=l26wang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.