emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el


From: Stefan Monnier
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]