From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Kelly Dean <kelly@prtime.org>
Cc: emacs-devel@gnu.org
Subject: Re: Why is Elisp's defvar weird? And is eval_sub broken?
Date: Mon, 16 Feb 2015 02:40:19 -0500 [thread overview]
Message-ID: <jwva90e5n6w.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <T14UWAM4jvM3cvNOA8ctoAvCcjPPIyHpEE99tC9HEx4@local> (Kelly Dean's message of "Mon, 16 Feb 2015 05:42:38 +0000")
> If Elisp's defvar with no init value is used, then it avoids conflict, but
> the packages that are a problem in the first place (by declaring
> non-package-prefixed symbols special) will also be ones that tend to use
> defvar _with_ an init value (so the symbols really are declared special, and
> their defvars are in the elc). Elisp's defvar doesn't prevent conflict in
> that case, so it seems the local-specialness feature doesn't fulfill its
> intended purpose.
That's indeed a risk, but it's one that's a lot easier to manage.
> In contrast, llet would prevent conflict in that case.
Right, you can introduce llet and llet* and then some more l<foos> for
macros that expand to uses of `let' or `let*' and ....
Or you can take a page from Common-Lisp's book and run with it.
I chose the second option. It's not perfect, but so far I don't regret it.
> (Global) specialness ambushes code that uses Lisp's standard «let», because
> «let» lets outside code decide how to bind the symbols.
That's true, which is why I added the annoying warnings to `defvar' when
the symbol seems not to use a prefix.
> And it happens to be faster.
It should make 0 difference to byte-compiled code and I don't care much
about the speed of the non-byte-compiled code.
> And dlet is a faster way of doing what you can currently do in Elisp using
> defvar (with no init value) followed by standard «let».
Again: no speed difference in byte-compiled code.
>> There is such a declaration already. It's called (defvar <foo>). Tada!
> Yes, though using defvar for this declaration in the function also causes
> local specialness, when all that's needed in this case is just to tell the
> byte compiler that the variables aren't mistakes.
Using the same identifiers sometimes as a lexical var and sometimes as
a dynamic var is evil for the poor human reader. Si I have no intention
to try and refine the semantics of such cases.
Stefan
next prev parent reply other threads:[~2015-02-16 7:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 21:32 Why is Elisp's defvar weird? And is eval_sub broken? Kelly Dean
2015-02-13 19:03 ` Stefan Monnier
2015-02-14 7:35 ` Kelly Dean
2015-02-14 14:36 ` Stefan Monnier
2015-02-15 14:17 ` Daniel Colascione
2015-02-16 5:42 ` Kelly Dean
2015-02-16 7:40 ` Stefan Monnier [this message]
2015-02-17 23:39 ` Kelly Dean
2015-02-18 22:29 ` Stefan Monnier
2015-02-19 10:32 ` Kelly Dean
2015-02-19 13:23 ` Stefan Monnier
2015-02-20 0:11 ` Kelly Dean
2015-02-20 2:02 ` Stefan Monnier
2015-02-22 4:11 ` Proposal for a closed-buffer tracker Kelly Dean
2015-02-22 15:53 ` Eli Zaretskii
2015-02-22 22:03 ` Stefan Monnier
2015-02-22 22:23 ` Dmitry Gutov
2015-02-23 13:53 ` Artur Malabarba
2015-02-23 16:44 ` Eli Zaretskii
2015-02-22 21:59 ` Stefan Monnier
2015-02-28 10:15 ` Artur Malabarba
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=jwva90e5n6w.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=kelly@prtime.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).