[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: |
Oleh Krehel |
Subject: |
Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el |
Date: |
Wed, 20 May 2015 10:46:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> (progv (mapcar #'car bindings)
>> (mapcar (lambda (x) (eval (cadr x))) bindings)
>> (funcall
>> `(lambda ()
>> (macroexpand-all
>> '(progn
>> ,@body))))))
>
> Hmm? Why this funcall+backquote+lambda business?
> [ Oh, and be careful to pass macroexpand-all-environment as second arg
> to macroexpand-all. ]
No reason, just copied it from `progv' and didn't simplify. Here's the
final version:
(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)))
>> The code in lisp-mode.el works fine, but there's still one thing on
>> which I'm not sure: what should happen if an `eval-when-compile' wrapper
>> is omitted?
>
> Same as what happens in your earlier let-opt when the `opt' is
> omitted.
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.
Should I install the patch?
Oleh
0001-Add-let-when-compile-macro-instead-of-using-pcase-le.patch
Description: Text Data
- Use the new let-opt macro in place of pcase-let in lisp-mode.el, Oleh Krehel, 2015/05/18
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Stefan Monnier, 2015/05/18
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Oleh Krehel, 2015/05/18
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Stefan Monnier, 2015/05/18
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Oleh Krehel, 2015/05/19
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Stefan Monnier, 2015/05/19
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el,
Oleh Krehel <=
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Stefan Monnier, 2015/05/20
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Oleh Krehel, 2015/05/20
- Re: Use the new let-opt macro in place of pcase-let in lisp-mode.el, Stefan Monnier, 2015/05/20