Skip to main content

4.2 Types

4.2.1 Data Type Definition

Information about type usage is located in the sections specified in Figure 4–1. Figure 4–7 lists some classes that are particularly relevant to the object system. Figure 9–1 lists the defined condition types.

Section Data Type
Section 4.3 (Classes) Object System types
Section 7.5 (Slots) Object System types
Chapter 7 (Objects) Object System types
Section 7.6 (Generic Functions and Methods) Object System types
Section 9.1 (Condition System Concepts) Condition System types
Chapter 4 (Types and Classes) Miscellaneous types
Chapter 2 (Syntax) All types—read and print syntax
Section 22.1 (The Lisp Printer) All types—print syntax
Section 3.2 (Compilation) All types—compilation issues

Figure 4–1. Cross-References to Data Type Information

4.2.2 Type Relationships

The types cons, symbol, array, number, character, hash-table, function, readtable, package, pathname, stream, random-state, condition, restart, and any single other type created by defstruct, define-condition, or defclass are pairwise disjoint, except for type relations explicitly established by specifying superclasses in defclass or define-condition or the :include option of destruct.

Any two types created by defstruct are disjoint unless one is a supertype of the other by virtue of the defstruct :include option.

Any two distinct classes created by defclass or define-condition are disjoint unless they have a common subclass or one class is a subclass of the other.

An implementation may be extended to add other subtype relationships between the specified types, as long as they do not violate the type relationships and disjointness requirements specified here. An implementation may define additional types that are subtypes or supertypes of any specified types, as long as each additional type is a subtype of type t and a supertype of type nil and the disjointness requirements are not violated.

At the discretion of the implementation, either standard-object or structure-object might appear in any class precedence list for a system class that does not already specify either standard-object or structure-object. If it does, it must precede the class t and follow all other standardized classes.

4.2.3 Type Specifiers

Type specifiers can be symbols, classes, or lists. Figure 4–2 lists symbols that are standardized atomic type specifiers, and Figure 4–3 lists standardized compound type specifier names. For syntax information, see the dictionary entry for the corresponding type specifier . It is possible to define new type specifiers using defclass, define-condition, defstruct, or deftype.

arithmetic-errorfunctionsimple-condition
arraygeneric-functionsimple-error
atomhash-tablesimple-string
base-charintegersimple-type-error
base-stringkeywordsimple-vector
bignumlistsimple-warning
bitlogical-pathnamesingle-float
bit-vectorlong-floatstandard-char
broadcast-streammethodstandard-class
built-in-classmethod-combinationstandard-generic-function
cell-errornilstandard-method
characternullstandard-object
classnumberstorage-condition
compiled-functionpackagestream
complexpackage-errorstream-error
concatenated-streamparse-errorstring
conditionpathnamestring-stream
consprint-not-readablestructure-class
control-errorprogram-errorstructure-object
division-by-zerorandom-statestyle-warning
double-floatratiosymbol
echo-streamrationalsynonym-stream
end-of-filereader-errort
errorreadtabletwo-way-stream
extended-charrealtype-error
file-errorrestartunbound-slot
file-streamsequenceunbound-variable
fixnumserious-conditionundefined-function
floatshort-floatunsigned-byte
floating-point-inexactsigned-bytevector
floating-point-invalid-operationsimple-arraywarning
floating-point-overflowsimple-base-string
floating-point-underflowsimple-bit-vector

Figure 4–2. Standardized Atomic Type Specifiers

If a type specifier is a list, the car of the list is a symbol, and the rest of the list is subsidiary type information. Such a type specifier is called a compound type specifier. Except as explicitly stated otherwise, the subsidiary items can be unspecified. The unspecified subsidiary items are indicated by writing *. For example, to completely specify a vector , the type of the elements and the length of the vector must be present.

(vector double-float 100)

The following leaves the length unspecified:

(vector double-float *)

The following leaves the element type unspecified:

(vector * 100)

Suppose that two type specifiers are the same except that the first has a * where the second has a more explicit specification. Then the second denotes a subtype of the type denoted by the first.

If a list has one or more unspecified items at the end, those items can be dropped. If dropping all occurrences of * results in a singleton list, then the parentheses can be dropped as well (the list can be replaced by the symbol in its car ). For example, (vector double-float *) can be abbreviated to (vector double-float), and (vector * *) can be abbreviated to (vector) and then to vector.

andlong-floatsimple-array
arraymembersimple-base-string
base-stringmodsimple-bit-vector
bit-vectornotsimple-string
complexorsimple-vector
consrationalsingle-float
double-floatrealstring
eqlsatisfiesunsigned-byte
floatshort-floatvalues
functionsigned-bytevector
integer

Figure 4–3. Standardized Compound Type Specifier Names

Figure 4–4 show the defined names that can be used as compound type specifier names but that cannot be used as atomic type specifiers.

andmodsatisfies
eqlnotvalues
memberor

Figure 4–4. Standardized Compound-Only Type Specifier Names

New type specifiers can come into existence in two ways.

Defining a structure by using defstruct without using the :type specifier or defining a class by using defclass or define-condition automatically causes the name of the structure or class to be a new type specifier symbol.

deftype can be used to define derived type specifiers, which act as ‘abbreviations’ for other type specifiers.

A class object can be used as a type specifier . When used this way, it denotes the set of all members of that class.

Figure 4–5 shows some defined names relating to types and declarations.

coercedefstructsubtypep
declaimdeftypethe
declareftypetype
defclasslocallytype-of
define-conditionproclaimtypep

Figure 4–5. Defined names relating to types and declarations.

Figure 4–6 shows all defined names that are type specifier names, whether for atomic type specifiers or compound type specifiers; this list is the union of the lists in Figure 4–2 and Figure 4–3.

andextended-charnilserious-conditionstandard-object
arithmetic-errorfile-errornotshort-floatstorage-condition
arrayfile-streamnullsigned-bytestream
atomfixnumnumbersimple-arraystream-error
base-charfloatorsimple-base-stringstring
base-stringfloating-point-inexactpackagesimple-bit-vectorstring-stream
bignumfloating-point-invalid-operationpackage-errorsimple-conditionstructure-class
bitfloating-point-overflowparse-errorsimple-errorstructure-object
bit-vectorfloating-point-underflowpathnamesimple-stringstyle-warning
broadcast-streamfunctionprint-not-readablesimple-type-errorsymbol
built-in-classgeneric-functionprogram-errorsimple-vectorsynonym-stream
cell-errorhash-tablerandom-statesimple-warningt
characterintegerratiosingle-floattwo-way-stream
classkeywordrationalstandard-chartype-error
compiled-functionlistreader-errorstandard-classunbound-slot
complexlogical-pathnamereadtablestandard-generic-functionunbound-variable
concatenated-streamlong-floatrealstandard-methodundefined-function
conditionmemberrestartunsigned-byte
consmethodsatisfiesvalues
control-errormethod-combinationsequencevector
division-by-zeromodwarning
double-float
echo-stream
end-of-file
eql
error

Figure 4–6. Standardized Type Specifier Names