Common Lisp the Language, 2nd Edition


next up previous contents index
Next: String Access Up: Common Lisp the Language Previous: Changing the Dimensions

18. Strings

A string is a specialized vector (one-dimensional array) whose elements are characters.

old_change_begin
Specifically, the type string is identical to the type (vector string-char), which in turn is the same as (array string-char (*)).
old_change_end

change_begin
X3J13 voted in March 1989 (CHARACTER-PROPOSAL)   to eliminate the type string-char and to redefine the type string to be the union of one or more specialized vector types, the types of whose elements are subtypes of the type character.
change_end

Any string-specific function defined in this chapter whose name begins with the prefix string will accept a symbol instead of a string as an argument provided that the operation never modifies that argument; the print name of the symbol is used.   In this respect the string-specific sequence operations are not simply specializations of generic versions; the generic sequence operations described in chapter 14 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 string to any argument whose data type is in doubt.

change_begin
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 2).
change_end

Also, there is a slight non-parallelism in the names of string functions. Where the suffixes equalp and eql would be more appropriate, for historical compatibility the suffixes equal and = are used instead to indicate case-insensitive and case-sensitive character comparison, respectively.

Any Lisp object may be tested for being a string by the predicate stringp.

Note that strings, like all vectors, may have fill pointers (though such strings are not necessarily simple). String operations generally operate only on the active portion of the string (below the fill pointer). See fill-pointer and related functions.




next up previous contents index
Next: String Access Up: Common Lisp the Language Previous: Changing the Dimensions


AI.Repository@cs.cmu.edu