From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Oleh Krehel <ohwoeowho@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el
Date: Wed, 20 May 2015 08:58:52 -0400 [thread overview]
Message-ID: <jwv8ucjmmt0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87oalftz4v.fsf@gmail.com> (Oleh Krehel's message of "Wed, 20 May 2015 10:46:24 +0200")
> (defmacro let-when-compile (bindings &rest body)
> "Like `let', but allows for compile time optimization.
> \n(fn BINDINGS BODY)"
> (declare (indent 1) (debug let))
> (cl-progv (mapcar #'car bindings)
> (mapcar (lambda (x) (eval (cadr x))) bindings)
> (macroexpand-all
> `(progn
> ,@body)
> macroexpand-all-environment)))
You can use `macroexp-progn' to avid adding `progn' when it's not needed,
but other than that, it looks good.
> So I guess it's fine. The byte compiler will issue a warning about an
> unbound variable if `eval-when-compile' is omitted by mistake. I was
> thinking maybe something clever could be done, like automatically
> leaving a let binding to prevent an error.
Leaving a let-binding behind would kind of defeat the purpose and would
lead to lots of byte-compiler warnings about unused variables.
> Should I install the patch?
Go ahead, yes, but please move let-when-compile to a generic file rather
than lisp-mode.el. I guess subr.el would make sense.
Stefan
next prev parent reply other threads:[~2015-05-20 12:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 15:16 Use the new let-opt macro in place of pcase-let in lisp-mode.el Oleh Krehel
2015-05-18 16:39 ` Stefan Monnier
2015-05-18 17:26 ` Oleh Krehel
2015-05-19 1:11 ` Stefan Monnier
2015-05-19 8:08 ` Oleh Krehel
2015-05-20 2:03 ` Stefan Monnier
2015-05-20 8:46 ` Oleh Krehel
2015-05-20 12:58 ` Stefan Monnier [this message]
2015-05-20 14:28 ` Oleh Krehel
2015-05-20 18:48 ` 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=jwv8ucjmmt0.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=ohwoeowho@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 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).