57 lines
3 KiB
HTML
57 lines
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>26.12.1. Data Types</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Data Types">
|
|
<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=tex2html4700 HREF="node252.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4698 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4692 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4702 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4703 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4701 HREF="node252.html"> Destructuring</A>
|
|
<B>Up:</B> <A NAME=tex2html4699 HREF="node250.html"> Miscellaneous Features</A>
|
|
<B> Previous:</B> <A NAME=tex2html4693 HREF="node250.html"> Miscellaneous Features</A>
|
|
<HR> <P>
|
|
<H2><A NAME=SECTION0030121000000000000000>26.12.1. Data Types</A></H2>
|
|
<P>
|
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
|
<A NAME=LOOPTYPESSECTION>Many</A>
|
|
loop constructs take a <i>type-spec</i> argument that
|
|
allows you to specify certain data types for loop variables.
|
|
While it is not necessary to specify a data type for any variable,
|
|
by doing so you ensure that the variable has a correctly typed initial
|
|
value. The type declaration is made available to the compiler for
|
|
more efficient <tt>loop</tt>
|
|
expansion.
|
|
In some implementations,
|
|
fixnum and float declarations are especially
|
|
useful; the compiler notices them and emits more efficient code.
|
|
<P>
|
|
The <i>type-spec</i> argument has the following syntax:
|
|
<PRE>
|
|
<i>type-spec</i> ::= <tt>of-type</tt> <i>d-type-spec</i>
|
|
<i>d-type-spec</i> ::= <i>type-specifier</i> | <tt>(<i>d-type-spec</i> . <i>d-type-spec</i>)</tt>
|
|
</PRE>
|
|
A <i>type-specifier</i> in this syntax can be any Common Lisp type
|
|
specifier. The <i>d-type-spec</i> argument is used for destructuring,
|
|
as described in section <A HREF="node252.html#LOOPDESTRUCTURINGSECTION">26.12.2</A>. If the
|
|
<i>d-type-spec</i> argument consists solely of the types <tt>fixnum</tt>,
|
|
<tt>float</tt>, <tt>t</tt>, or <tt>nil</tt>, the <tt>of-type</tt> keyword is optional. The
|
|
<tt>of-type</tt> construct is optional in these cases to provide backward
|
|
compatibility; thus the following two expressions are the same:
|
|
<P>
|
|
<P><pre>
|
|
;;; This expression uses the old syntax for type specifiers.
|
|
(loop for i fixnum upfrom 3 ...) <BR><BR>;;; This expression uses the new syntax for type specifiers.
|
|
(loop for i of-type fixnum upfrom 3 ...)
|
|
</pre><P>
|
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
|
<P>
|
|
<HR>
|
|
<P><ADDRESS>
|
|
AI.Repository@cs.cmu.edu
|
|
</ADDRESS>
|
|
</BODY>
|