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.
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
.
and | long-float | simple-base-string |
array | member | simple-bit-vector |
base-string | mod | simple-string |
bit-vector | not | simple-vector |
complex | or | single-float |
cons | rational | string |
double-float | real | unsigned-byte |
eql | satisfies | values |
float | short-float | vector |
function | signed-byte | |
integer | simple-array |
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.
and | mod | satisfies |
eql | not | values |
member | or |
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.
coerce | defstruct | subtypep |
declaim | deftype | the |
declare | ftype | type |
defclass | locally | type-of |
define-condition | proclaim | typep |
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.