Function: lambda

lambda is a macro defined in subr.el.gz.

Signature

(lambda ARGS [DOCSTRING] [INTERACTIVE] BODY)

Documentation

Return an anonymous function.

Under dynamic binding, a call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is self-quoting; the result of evaluating the lambda expression is the expression itself. Under lexical binding, the result is a closure. Regardless, the result is a 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. DOCSTRING is an optional documentation string.
 If present, it should describe how to call the function.
 But documentation strings are usually not useful in nameless functions.
INTERACTIVE should be a call to the function interactive, which see. It may also be omitted. BODY should be a list of Lisp expressions.

Probably introduced at or before Emacs version 1.4.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro lambda (&rest cdr)
  "Return an anonymous function.
Under dynamic binding, a call of the form (lambda ARGS DOCSTRING
INTERACTIVE BODY) is self-quoting; the result of evaluating the
lambda expression is the expression itself.  Under lexical
binding, the result is a closure.  Regardless, the result is a
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'.
DOCSTRING is an optional documentation string.
 If present, it should describe how to call the function.
 But documentation strings are usually not useful in nameless functions.
INTERACTIVE should be a call to the function `interactive', which see.
It may also be omitted.
BODY should be a list of Lisp expressions.

\(fn ARGS [DOCSTRING] [INTERACTIVE] BODY)"
  (declare (doc-string 2) (indent defun)
           (debug (&define lambda-list lambda-doc
                           [&optional ("interactive" interactive)]
                           def-body)))
  ;; Note that this definition should not use backquotes; subr.el should not
  ;; depend on backquote.el.
  (list 'function (cons 'lambda cdr)))