all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Constantin Kulikov <zxnotdead@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:))
Date: Fri, 23 Sep 2016 15:03:39 -0400	[thread overview]
Message-ID: <jwvr38acumz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAFkz2yqCHpdjr7u9f3Bov1smzFoqOrMhBnHHCC=dK=c1aM7_jg@mail.gmail.com> (Constantin Kulikov's message of "Fri, 23 Sep 2016 20:19:36 +0300")

> 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



  reply	other threads:[~2016-09-23 19:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 16:43 Lambda in macrolet becomes a closure? (another breaking change in emacs:)) Constantin Kulikov
2016-09-19 18:12 ` Stefan Monnier
2016-09-23 16:01   ` Michael Heerdegen
2016-09-23 16:13     ` Stefan Monnier
2016-09-23 17:19 ` Constantin Kulikov
2016-09-23 19:03   ` Stefan Monnier [this message]
2016-09-25 11:06     ` Constantin Kulikov
2016-09-25 14:15       ` Stefan Monnier
2016-09-25 18:01   ` Michael Heerdegen
2016-09-25 18:53     ` Stefan Monnier
2016-09-27  9:13     ` Constantin Kulikov
2016-09-27  9:19       ` Constantin Kulikov
2016-09-27 11:53         ` Constantin Kulikov
2016-09-27 14:57           ` Michael Heerdegen

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvr38acumz.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=zxnotdead@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.