From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Tomohiro Matsuyama <tomo@cx4a.org>
Cc: emacs-devel@gnu.org
Subject: Re: Should lexical-let use let in the situation lexical-binding is t ?
Date: Tue, 18 Sep 2012 08:44:39 -0400 [thread overview]
Message-ID: <jwv392f5x9e.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20120918192807.6a426ea58372355516a2ea50@cx4a.org> (Tomohiro Matsuyama's message of "Tue, 18 Sep 2012 19:28:07 +0900")
> I'm not sure that is valid, but if so, I think we should modify
> lexical-let to improve performance.
As mentioned in my reply there, the two aren't quite compatible (because
(lexical-let ((tab-width 4)) foo) will be a lexical binding, whereas
(let ((tab-width 4)) foo) will be a dynamic binding) so we could do
that, but only after checking that the lexical-let-bound variable is not
defvar'd, and this requires checking byte-compile-bound-variables, so it's
rather ugly to do from a macro.
Furthermore, it can be non-trivial for the macro to figure out whether
it's really called in a lexical-binding context or not and whether
byte-compile-bound-variables is relevant, since the macro call being
expanded might come from code being executed during compilation
(e.g. loaded via a `require') rather than from code being compiled.
I've recently tightened a bit the way lexical-binding is set, so that
testing `lexical-binding' in a macro should now be fairly accurate (the
C code rebinds lexical-binding during macro-calls to reflect whether the
macro is expanded in a lexical-binding context or not, rather than
leaving the variable's value determined by the current-buffer's local
value), but testing byte-compile-bound-variables is likely to
be unreliable.
IOW, it's OK for the OP to use such a macro himself because he hopefully
won't fall into those traps in those places where he uses it, but if we
do right in lexical-let so that it applies to all uses of lexical-let,
there's a good chance we could bump into those problems, and they may be
very difficult to track down.
Stefan
next prev parent reply other threads:[~2012-09-18 12:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 10:28 Should lexical-let use let in the situation lexical-binding is t ? Tomohiro Matsuyama
2012-09-18 12:44 ` Stefan Monnier [this message]
2012-09-18 22:42 ` Richard Stallman
2012-09-19 0:41 ` Stefan Monnier
2012-09-19 14:12 ` Richard Stallman
2012-09-19 19:01 ` Stefan Monnier
2012-09-19 22:06 ` Sam Steingold
2012-09-20 3:26 ` Stefan Monnier
2012-09-20 15:06 ` Sam Steingold
2012-09-19 1:20 ` Sam Steingold
2012-09-19 7:43 ` Nix
2012-09-21 18:18 ` Tomohiro Matsuyama
2012-09-21 21:18 ` 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=jwv392f5x9e.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=tomo@cx4a.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.