87 lines
5 KiB
HTML
87 lines
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>18. Strings</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Strings">
|
|
<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=tex2html3571 HREF="node165.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3569 HREF="clm.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3563 HREF="node163.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3573 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3574 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3572 HREF="node165.html"> String Access</A>
|
|
<B>Up:</B> <A NAME=tex2html3570 HREF="clm.html">Common Lisp the Language</A>
|
|
<B> Previous:</B> <A NAME=tex2html3564 HREF="node163.html"> Changing the Dimensions </A>
|
|
<HR> <P>
|
|
<H1><A NAME=SECTION002200000000000000000>18. Strings</A></H1>
|
|
<P>
|
|
A string is a specialized vector (one-dimensional array)
|
|
whose elements are characters.
|
|
<P>
|
|
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
|
|
Specifically, the type <tt>string</tt>
|
|
is identical to the type <tt>(vector string-char)</tt>, which in turn
|
|
is the same as <tt>(array string-char (*))</tt>.
|
|
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
|
|
<P>
|
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
|
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=18130> </A>
|
|
to eliminate the type <tt>string-char</tt> and to redefine the type
|
|
<tt>string</tt> to be the union of one or more specialized vector
|
|
types, the types of whose elements are subtypes of the type <tt>character</tt>.
|
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
|
<P>
|
|
Any string-specific function defined in this chapter
|
|
whose name begins with the prefix <tt>string</tt>
|
|
will accept a symbol instead of a string
|
|
as an argument <i>provided</i> that the operation never modifies that argument;
|
|
the print name of the symbol is used.
|
|
<A NAME=18137> </A>
|
|
In this respect the string-specific sequence operations are not
|
|
simply specializations of generic versions; the generic sequence
|
|
operations described in chapter <A HREF="node141.html#KSEQUE">14</A> never accept symbols as sequences.
|
|
This slight inelegance is permitted in Common Lisp in the name of pragmatic utility.
|
|
One may get the effect of having a generic sequence function
|
|
operate on either symbols or strings by applying the coercion
|
|
function <tt>string</tt> to any argument whose data type is in doubt.
|
|
<p>
|
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
|
Note that this remark, predating the design of the Common Lisp Object System,
|
|
uses the term ``generic'' in a generic sense and not necessarily
|
|
in the technical sense used by CLOS
|
|
(see chapter <A HREF="node15.html#DTYPES">2</A>).
|
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
|
<P>
|
|
Also, there is a slight non-parallelism in the names of string functions.
|
|
Where the suffixes <tt>equalp</tt> and <tt>eql</tt> would be more appropriate,
|
|
for historical compatibility the suffixes <tt>equal</tt> and <tt>=</tt> are used instead
|
|
to indicate case-insensitive and case-sensitive character comparison,
|
|
respectively.
|
|
<P>
|
|
Any Lisp object may be tested for being a string by
|
|
the predicate <tt>stringp</tt>.
|
|
<P>
|
|
Note that strings, like all vectors, may have fill pointers
|
|
(though such strings are not necessarily <i>simple</i>).
|
|
String operations generally operate only on the active portion of the string
|
|
(below the fill pointer). See <tt>fill-pointer</tt> and related
|
|
functions.
|
|
<P>
|
|
<HR>
|
|
<UL>
|
|
<LI> <A NAME=tex2html3575 HREF="node165.html#SECTION002210000000000000000"> String Access</A>
|
|
<LI> <A NAME=tex2html3576 HREF="node166.html#SECTION002220000000000000000"> String Comparison</A>
|
|
<LI> <A NAME=tex2html3577 HREF="node167.html#SECTION002230000000000000000"> String Construction and Manipulation</A>
|
|
</UL>
|
|
<BR> <HR><A NAME=tex2html3571 HREF="node165.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3569 HREF="clm.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3563 HREF="node163.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3573 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3574 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3572 HREF="node165.html"> String Access</A>
|
|
<B>Up:</B> <A NAME=tex2html3570 HREF="clm.html">Common Lisp the Language</A>
|
|
<B> Previous:</B> <A NAME=tex2html3564 HREF="node163.html"> Changing the Dimensions </A>
|
|
<HR> <P>
|
|
<HR>
|
|
<P><ADDRESS>
|
|
AI.Repository@cs.cmu.edu
|
|
</ADDRESS>
|
|
</BODY>
|