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

70 lines
4.3 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>7.1. Constants and Variables</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Constants and Variables">
<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=tex2html2488 HREF="node78.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2486 HREF="node76.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2480 HREF="node76.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2490 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2491 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html2489 HREF="node78.html"> Reference</A>
<B>Up:</B> <A NAME=tex2html2487 HREF="node76.html"> Control Structure</A>
<B> Previous:</B> <A NAME=tex2html2481 HREF="node76.html"> Control Structure</A>
<HR> <P>
<H1><A NAME=SECTION001110000000000000000>7.1. Constants and Variables</A></H1>
<P>
<A NAME=FUNCTIONNAMESECTION>
Because</A> some Lisp data objects are used to represent programs,
one cannot always notate a constant data object in a program simply
by writing the notation for the object unadorned; it would be ambiguous
whether a constant object or a program fragment was intended.
The <tt>quote</tt> special form resolves this ambiguity.
<P>
There are two kinds of variables in Common Lisp, in effect: ordinary
variables and function names. There are some similarities between
the two kinds, and in a few cases there are similar functions for
dealing with them, for example <tt>boundp</tt> and <tt>fboundp</tt>.
However, for the most part the two kinds of variables are
used for very different purposes: one to name defined functions,
macros, and special forms, and the other to name data objects.
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
X3J13 voted in March 1989 (FUNCTION-NAME) <A NAME=4797>&#160;</A> to introduce the concept
of a <i>function-name</i>, which may be either a symbol or a two-element list whose
first element is the symbol <tt>setf</tt> and whose second element is a symbol.
The primary purpose of this is to allow <tt>setf</tt> expander functions to be
CLOS generic functions with user-defined methods.
Many places in Common Lisp that used to require a symbol for a function
name are changed to allow 2-lists as well; for example, <tt>defun</tt>
is changed so that one may write <tt>(defun (setf foo) ...)</tt>,
and the <tt>function</tt> special form is changed to accept any function-name.
See also <tt>fdefinition</tt>.
<P>
By convention, any function named <tt>(setf <i>f</i>)</tt> should return its first
argument as its only value, in order to preserve the specification that
<tt>setf</tt> returns its <i>newvalue</i>. See <tt>setf</tt>.
<P>
Implementations are free to extend the syntax of function-names to
include lists beginning with additional symbols other than <tt>setf</tt>
or <tt>lambda</tt>.
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<HR>
<UL>
<LI> <A NAME=tex2html2492 HREF="node78.html#SECTION001111000000000000000"> Reference</A>
<LI> <A NAME=tex2html2493 HREF="node79.html#SECTION001112000000000000000"> Assignment</A>
</UL>
<BR> <HR><A NAME=tex2html2488 HREF="node78.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2486 HREF="node76.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2480 HREF="node76.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2490 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2491 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html2489 HREF="node78.html"> Reference</A>
<B>Up:</B> <A NAME=tex2html2487 HREF="node76.html"> Control Structure</A>
<B> Previous:</B> <A NAME=tex2html2481 HREF="node76.html"> Control Structure</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>