emacs-devel
[Top][All Lists]
Advanced

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

Re: Lambda in macrolet becomes a closure? (another breaking change in em


From: Stefan Monnier
Subject: Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:))
Date: Sun, 25 Sep 2016 14:53:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

>> [...] then how I can decide how to quote this value [...]?
> By looking at the value (or do I miss something)?

> #+begin_src emacs-lisp
> (let ((var 1))
>   (let* ((fu #'(lambda (a) (+ a var)))
>          ba)
>     (message "%s" `,fu)
>     (setq ba (byte-compile `(lambda (b) (funcall ,(if (equal (car-safe fu) 
> 'lambda) `#',fu `',fu) b))))
>     (funcall ba 3)))
> #+end_src

FWIW, in this case, the byte-compiler's warning is incorrect: it tries
to warn the programmer about the all-too common habit of using '(lambda
...) instead of #'(lambda ....) in the source code, but in the present
example, the quoted (lambda ...) is actually indeed a function value we
want to quote as-is rather than a function expression.

So I think it's better to use with-no-warnings (which I generally don't
like to use) than to do as above, which feels like a hack.

Of course, taking a step back, if the whole code gets byte-compiled (as
it should), then the problem doesn't even appear since #'(lambda (a) (+
a var)) will not evaluate to (lambda (a) (+ a var)) but to a bytecoded
function (which needs to be quoted with `quote` rather than with
`function`).


        Stefan




reply via email to

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