Function: function
function is a special form defined in eval.c.
Signature
(function ARG)
Documentation
Like quote, but preferred for objects which are functions.
In byte compilation, function causes its argument to be handled by
the byte compiler. Similarly, when expanding macros and expressions,
ARG can be examined and possibly expanded. If quote is used
instead, this doesn't happen.
Probably introduced at or before Emacs version 1.1.
Source Code
// Defined in /usr/src/emacs/src/eval.c
{
Lisp_Object quoted = XCAR (args);
if (!NILP (XCDR (args)))
xsignal2 (Qwrong_number_of_arguments, Qfunction, Flength (args));
if (!NILP (Vinternal_interpreter_environment)
&& CONSP (quoted)
&& EQ (XCAR (quoted), Qlambda))
{ /* This is a lambda expression within a lexical environment;
return an interpreted closure instead of a simple lambda. */
Lisp_Object cdr = XCDR (quoted);
Lisp_Object tmp = cdr;
if (CONSP (tmp)
&& (tmp = XCDR (tmp), CONSP (tmp))
&& (tmp = XCAR (tmp), CONSP (tmp))
&& (EQ (QCdocumentation, XCAR (tmp))))
{ /* Handle the special (:documentation <form>) to build the docstring
dynamically. */
Lisp_Object docstring = eval_sub (Fcar (XCDR (tmp)));
CHECK_STRING (docstring);
cdr = Fcons (XCAR (cdr), Fcons (docstring, XCDR (XCDR (cdr))));
}
return Fcons (Qclosure, Fcons (Vinternal_interpreter_environment,
cdr));
}
else
/* Simply quote the argument. */
return quoted;
}