From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Is add-to-list supposed to work when lexical-binding is t?
Date: Mon, 03 Jun 2013 21:49:58 -0400 [thread overview]
Message-ID: <jwvr4giwt3x.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: 1370306529.4188.YahooMailClassic@web141101.mail.bf1.yahoo.com
> Section 11.9.3 (Lexical Binding) in the manual says "functions like
> `symbol-value', `boundp', and `set' only retrieve or modify
> a variable's dynamic binding". Why?
Because a variable is not the same thing as a symbol.
For dynamic binding, you can somewhat blur the difference and use the
symbol's value cell as "the content of the variable of that name"
because let-binding just temporarily changes the only global value.
With lexical scoping, a given variable name can have many different
values at the same time so this is not an option.
> (let ((x '(a))) (add-to-list 'x 'b) x) -> (b a)
Yup, this is asking for trouble. Use `push' or `cl-pushnew' instead.
Stefan
next prev parent reply other threads:[~2013-06-04 1:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 0:42 Is add-to-list supposed to work when lexical-binding is t? Kelly Dean
2013-06-04 1:49 ` Stefan Monnier [this message]
2013-06-04 15:24 ` PJ Weisberg
2013-06-05 2:41 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2013-06-05 23:12 Kelly Dean
2013-06-06 0:42 ` Stefan Monnier
2013-06-10 1:43 Kelly Dean
2013-06-10 7:56 ` Stefan Monnier
[not found] <mailman.1311.1370828650.22516.help-gnu-emacs@gnu.org>
2013-06-10 5:12 ` Barry Margolin
2013-06-12 0:59 Kelly Dean
[not found] <mailman.1450.1370998793.22516.help-gnu-emacs@gnu.org>
2013-06-13 14:57 ` Stefan Monnier
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=jwvr4giwt3x.fsf-monnier+gmane.emacs.help@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=help-gnu-emacs@gnu.org \
/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.