[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: |
Fri, 23 Sep 2016 15:03:39 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> and it seems to work well, but
>
> (setq lexical-binding nil)
> (let* ((fu #'(lambda (a) (+ a 1)))
> ba)
> (message "%s" `,fu)
> (let (byte-compile-warnings)
> (setq ba (byte-compile `(lambda (b) (funcall (quote ,fu) b)))))
> (funcall ba 2))
>
> results in a *Compile-Log* buffer pop up with
>
> Warning: (lambda (a) ...) quoted with ' rather than with #'
Notice it says "warning", not "error".
> So (if I understend correctly) I can not predict that the value of the `fu'
> will be a (closure ...) or a (lambda ...),
Or any other object that can be passed to `funcall`, indeed.
> then how I can decide how to quote this value or silence the warning?
If you're worried about the warning, silence it with
`with-no-warnings`, since in this particular case you know that the
(lambda ()...) is a function *value* and not a function expression,
hence the warning is incorrect.
We could *fix* the warning once and for all by changing the
implementation of the `function` special form so that it just always
returns a (closure ...), so that (lambda ...) is only ever used as
a source code expression and never as a function value. I think it
would be a good change, but I expect lots of people would complain about
such a gratuitous change.
Stefan
- Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Constantin Kulikov, 2016/09/19
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Stefan Monnier, 2016/09/19
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Constantin Kulikov, 2016/09/23
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)),
Stefan Monnier <=
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Michael Heerdegen, 2016/09/25
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Stefan Monnier, 2016/09/25
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Constantin Kulikov, 2016/09/27
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Constantin Kulikov, 2016/09/27
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Constantin Kulikov, 2016/09/27
- Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:)), Michael Heerdegen, 2016/09/27