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: Tue, 04 Jun 2013 22:41:59 -0400 [thread overview]
Message-ID: <jwv38sxth9n.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: CAJsNXT=da5V5OTAAfyPEuR9aDoNs+Y4gmfb1SZjcFYBxyFBF-A@mail.gmail.com
>> > (let ((x '(a))) (add-to-list 'x 'b) x) -> (b a)
>> Yup, this is asking for trouble. Use `push' or `cl-pushnew' instead.
> Unless you're knee-deep in the internals of the language, the difference
> between `cl-pushnew' and `add-to-list' is so obscure as to be
> incomprehensible.
Agreed. I never liked add-to-list, and now I really know why.
To give you an idea of why `add-to-list' is a problem:
(add-to-list 'o 'b)
does the same as
(add-to-list (intern (substring "ouch" 0 1)) 'b)
so other than by ad-hoc handling the case where the first arg is passed
via quoting, the byte-compiler would have to handle both cases, and the
second case is pretty hopeless.
Stefan
next prev parent reply other threads:[~2013-06-05 2:41 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
2013-06-04 15:24 ` PJ Weisberg
2013-06-05 2:41 ` Stefan Monnier [this message]
-- 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv38sxth9n.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).