[Top][All Lists]

[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: Mon, 19 Sep 2016 14:12:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> in emacs version "", 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.


reply via email to

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