Note that lex bound lambda forms are not self-quoting (Bug#33199)
* doc/lispref/functions.texi (Anonymous Functions): * lisp/subr.el (lambda): Note that under lexical binding a lambda form yields a closure object (Bug#33199).
This commit is contained in:
parent
fa605f242e
commit
39e85a0c6c
2 changed files with 13 additions and 9 deletions
|
@ -1082,15 +1082,18 @@ This macro returns an anonymous function with argument list
|
||||||
@var{args}, documentation string @var{doc} (if any), interactive spec
|
@var{args}, documentation string @var{doc} (if any), interactive spec
|
||||||
@var{interactive} (if any), and body forms given by @var{body}.
|
@var{interactive} (if any), and body forms given by @var{body}.
|
||||||
|
|
||||||
In effect, this macro makes @code{lambda} forms self-quoting:
|
Under dynamic binding, this macro effectively makes @code{lambda}
|
||||||
evaluating a form whose @sc{car} is @code{lambda} yields the form
|
forms self-quoting: evaluating a form whose @sc{car} is @code{lambda}
|
||||||
itself:
|
yields the form itself:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
(lambda (x) (* x x))
|
(lambda (x) (* x x))
|
||||||
@result{} (lambda (x) (* x x))
|
@result{} (lambda (x) (* x x))
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
Note that when evaluting under lexical binding the result is a closure
|
||||||
|
object (@pxref{Closures}).
|
||||||
|
|
||||||
The @code{lambda} form has one other effect: it tells the Emacs
|
The @code{lambda} form has one other effect: it tells the Emacs
|
||||||
evaluator and byte-compiler that its argument is a function, by using
|
evaluator and byte-compiler that its argument is a function, by using
|
||||||
@code{function} as a subroutine (see below).
|
@code{function} as a subroutine (see below).
|
||||||
|
|
13
lisp/subr.el
13
lisp/subr.el
|
@ -93,12 +93,13 @@ Info node `(elisp)Specification List' for details."
|
||||||
`(put (quote ,symbol) 'edebug-form-spec (quote ,spec)))
|
`(put (quote ,symbol) 'edebug-form-spec (quote ,spec)))
|
||||||
|
|
||||||
(defmacro lambda (&rest cdr)
|
(defmacro lambda (&rest cdr)
|
||||||
"Return a lambda expression.
|
"Return an anonymous function.
|
||||||
A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
|
Under dynamic binding, a call of the form (lambda ARGS DOCSTRING
|
||||||
self-quoting; the result of evaluating the lambda expression is the
|
INTERACTIVE BODY) is self-quoting; the result of evaluating the
|
||||||
expression itself. The lambda expression may then be treated as a
|
lambda expression is the expression itself. Under lexical
|
||||||
function, i.e., stored as the function value of a symbol, passed to
|
binding, the result is a closure. Regardless, the result is a
|
||||||
`funcall' or `mapcar', etc.
|
function, i.e., it may be stored as the function value of a
|
||||||
|
symbol, passed to `funcall' or `mapcar', etc.
|
||||||
|
|
||||||
ARGS should take the same form as an argument list for a `defun'.
|
ARGS should take the same form as an argument list for a `defun'.
|
||||||
DOCSTRING is an optional documentation string.
|
DOCSTRING is an optional documentation string.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue