all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Lambda in macrolet becomes a closure? (another breaking change in emacs:))
Date: Mon, 19 Sep 2016 14:12:17 -0400	[thread overview]
Message-ID: <jwvk2e7ix31.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: CAFkz2yq3qxGmY1op5CtoUj7WVGQedm3mnjeL79VYB6F9X_AWDA@mail.gmail.com

> in emacs version "25.1.50.2", this:
> (macrolet ((tm () (let ((fu #'(lambda () t)))
>                            `(list ,fu))))
>            (tm))

Here, `fu' is a function *value*, rather than a function *expression*
(where I take those words to mean that an /expression/ is what you pass
to `eval` and that returns ` /value/).

In `(list ,fu) you take that value and plug it into the source code,
which in general might not work correctly (although you may often get
lucky since in Elisp, many values are "self-quoting" meaning that they
are also valid expressions which evaluate to themselves).

> gives an errror: Symbol’s function definition is void: closure

Indeed, in a lexical-binding context, a function value will sometimes
look like (closure ...) which is not a valid expression (there is no
function nor macro named `closure').

> (macrolet ((tm () (let ((fu #'(lambda () t)))
>                            `(list (function ,fu)))))
>            (tm))
> returns ((closure (t) nil t))

This will sometimes work as well.  Probably more often than the previous
example.  Yet it's still not correct.  To quote a value, you want to use
`quote` rather than `function`.  `function` can only be used reliably to
quote a "function expression" rather than a function value.  A function
expression is basically either a symbol (the name of a function), or
a sexp of the form (lambda <args> <body>).

> in emacs "24.3.1", both variants returns ((lambda nil t))

Yes, sometimes.


        Stefan




  reply	other threads:[~2016-09-19 18:12 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 [this message]
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
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=jwvk2e7ix31.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /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.