aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-10-29 19:01:07 -0400
committerNoam Postavsky2018-11-08 20:13:56 -0500
commit39e85a0c6c8de75b446e8e4dc41cdfdca96907e3 (patch)
treea95b5bece57c76052fcad728e1de962ba2d3fee2
parentfa605f242eec680b2c7d1374d1405510818d9103 (diff)
downloademacs-39e85a0c6c8de75b446e8e4dc41cdfdca96907e3.tar.gz
emacs-39e85a0c6c8de75b446e8e4dc41cdfdca96907e3.zip
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).
-rw-r--r--doc/lispref/functions.texi9
-rw-r--r--lisp/subr.el13
2 files changed, 13 insertions, 9 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 242d754dea9..216666c713a 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -1082,15 +1082,18 @@ This macro returns an anonymous function with argument list
1082@var{args}, documentation string @var{doc} (if any), interactive spec 1082@var{args}, documentation string @var{doc} (if any), interactive spec
1083@var{interactive} (if any), and body forms given by @var{body}. 1083@var{interactive} (if any), and body forms given by @var{body}.
1084 1084
1085In effect, this macro makes @code{lambda} forms self-quoting: 1085Under dynamic binding, this macro effectively makes @code{lambda}
1086evaluating a form whose @sc{car} is @code{lambda} yields the form 1086forms self-quoting: evaluating a form whose @sc{car} is @code{lambda}
1087itself: 1087yields the form itself:
1088 1088
1089@example 1089@example
1090(lambda (x) (* x x)) 1090(lambda (x) (* x x))
1091 @result{} (lambda (x) (* x x)) 1091 @result{} (lambda (x) (* x x))
1092@end example 1092@end example
1093 1093
1094Note that when evaluting under lexical binding the result is a closure
1095object (@pxref{Closures}).
1096
1094The @code{lambda} form has one other effect: it tells the Emacs 1097The @code{lambda} form has one other effect: it tells the Emacs
1095evaluator and byte-compiler that its argument is a function, by using 1098evaluator and byte-compiler that its argument is a function, by using
1096@code{function} as a subroutine (see below). 1099@code{function} as a subroutine (see below).
diff --git a/lisp/subr.el b/lisp/subr.el
index 59f6949b211..d09789340fc 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -93,12 +93,13 @@ Info node `(elisp)Specification List' for details."
93 `(put (quote ,symbol) 'edebug-form-spec (quote ,spec))) 93 `(put (quote ,symbol) 'edebug-form-spec (quote ,spec)))
94 94
95(defmacro lambda (&rest cdr) 95(defmacro lambda (&rest cdr)
96 "Return a lambda expression. 96 "Return an anonymous function.
97A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is 97Under dynamic binding, a call of the form (lambda ARGS DOCSTRING
98self-quoting; the result of evaluating the lambda expression is the 98INTERACTIVE BODY) is self-quoting; the result of evaluating the
99expression itself. The lambda expression may then be treated as a 99lambda expression is the expression itself. Under lexical
100function, i.e., stored as the function value of a symbol, passed to 100binding, the result is a closure. Regardless, the result is a
101`funcall' or `mapcar', etc. 101function, i.e., it may be stored as the function value of a
102symbol, passed to `funcall' or `mapcar', etc.
102 103
103ARGS should take the same form as an argument list for a `defun'. 104ARGS should take the same form as an argument list for a `defun'.
104DOCSTRING is an optional documentation string. 105DOCSTRING is an optional documentation string.