emacs.d/clones/lisp/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node62.html

46 lines
2.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>5.2. Functions</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Functions">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html2285 HREF="node63.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2283 HREF="node55.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2277 HREF="node61.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2287 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2288 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html2286 HREF="node63.html"> Named Functions</A>
<B>Up:</B> <A NAME=tex2html2284 HREF="node55.html"> Program Structure</A>
<B> Previous:</B> <A NAME=tex2html2278 HREF="node61.html"> Function Calls</A>
<HR> <P>
<H1><A NAME=SECTION00920000000000000000>5.2. Functions</A></H1>
<P>
There are two ways to indicate a function to be used in a function-call
form. One is to use a symbol that names the function. This use of
symbols to name functions is completely independent of their use in
naming special and lexical variables. The other way is to use a
<i>lambda-expression</i>, which is a list whose first element is the symbol
<tt>lambda</tt>. A lambda-expression is <i>not</i> a form; it cannot be
meaningfully evaluated. Lambda-expressions and symbols, when used in
programs as names of functions, can appear only as the first element of a
function-call form, or as the second element of the <tt>function</tt>
special form. Note that symbols and lambda-expressions are treated as
<i>names</i> of functions in these two contexts. This should be
distinguished from the treatment of symbols and lambda-expressions as
<i>function objects</i>, that is,
objects that satisfy the predicate <tt>functionp</tt>,
as when giving such an object to <tt>apply</tt> or <tt>funcall</tt> to be
invoked.
<P>
<HR>
<UL>
<LI> <A NAME=tex2html2289 HREF="node63.html#SECTION00921000000000000000"> Named Functions</A>
<LI> <A NAME=tex2html2290 HREF="node64.html#SECTION00922000000000000000"> Lambda-Expressions</A>
</UL>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>