A type is a (possibly infinite) set of objects. An object can belong to more than one type. Types are never explicitly represented as objects by Common Lisp. Instead, they are referred to indirectly by the use of type specifiers, which are objects that denote types.
New types can be defined using deftype, defstruct, defclass, and define-condition.
The function typep, a set membership test, is used to determine whether a given object is of a given type. The function subtypep, a subset test, is used to determine whether a given type is a subtype of another given type. The function type-of returns a particular type to which a given object belongs, even though that object must belong to one or more other types as well. (For example, every object is of type t, but type-of always returns a type specifier for a type more specific than t.)
Objects, not variables, have types. Normally, any variable can have any object as its value. It is possible to declare that a variable takes on only values of a given type by making an explicit type declaration. Types are arranged in a directed acyclic graph, except for the presence of equivalences.
Declarations can be made about types using declare, proclaim, declaim, or the. For more information about declarations, see section Declarations.
Among the fundamental objects of the object system are classes. A class determines the structure and behavior of a set of other objects, which are called its instances. Every object is a direct instance of a class. The class of an object determines the set of operations that can be performed on the object. For more information, see section Classes.
It is possible to write functions that have behavior specialized to the class of the objects which are their arguments. For more information, see section Generic Functions and Methods.
The class of the class of an object is called its metaclass @IGindex{metaclass} . For more information about metaclasses, see section Meta-Objects.
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 Classes Object System types section Slots Object System types section Objects Object System types section Generic Functions and Methods Object System types section Condition System Concepts Condition System types section Types and Classes Miscellaneous types section Syntax All types--read and print syntax section The Lisp Printer All types--print syntax section Compilation All types--compilation issues
Figure 4--1: Cross-References to Data Type Information
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-error function simple-condition array generic-function simple-error atom hash-table simple-string base-char integer simple-type-error base-string keyword simple-vector bignum list simple-warning bit logical-pathname single-float bit-vector long-float standard-char broadcast-stream method standard-class built-in-class method-combination standard-generic-function cell-error nil standard-method character null standard-object class number storage-condition compiled-function package stream complex package-error stream-error concatenated-stream parse-error string condition pathname string-stream cons print-not-readable structure-class control-error program-error structure-object division-by-zero random-state style-warning double-float ratio symbol echo-stream rational synonym-stream end-of-file reader-error t error readtable two-way-stream extended-char real type-error file-error restart unbound-slot file-stream sequence unbound-variable fixnum serious-condition undefined-function float short-float unsigned-byte floating-point-inexact signed-byte vector floating-point-invalid-operation simple-array warning floating-point-overflow simple-base-string floating-point-underflow simple-bit-vector
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes:
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes:
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes:
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes:
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes:
Figure 4--2: Standardized Atomic Type Specifiers
\indent 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 @IGindex{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--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.
and mod satisfies eql not values member or
Figure 4--4: Standardized Compound-Only Type Specifier Names
New type specifiers can come into existence in two ways.
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--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.
and function simple-array arithmetic-error generic-function simple-base-string array hash-table simple-bit-vector atom integer simple-condition base-char keyword simple-error base-string list simple-string bignum logical-pathname simple-type-error bit long-float simple-vector bit-vector member simple-warning broadcast-stream method single-float built-in-class method-combination standard-char cell-error mod standard-class character nil standard-generic-function class not standard-method compiled-function null standard-object complex number storage-condition concatenated-stream or stream condition package stream-error cons package-error string control-error parse-error string-stream division-by-zero pathname structure-class double-float print-not-readable structure-object echo-stream program-error style-warning end-of-file random-state symbol eql ratio synonym-stream error rational t extended-char reader-error two-way-stream file-error readtable type-error file-stream real unbound-slot fixnum restart unbound-variable float satisfies undefined-function floating-point-inexact sequence unsigned-byte floating-point-invalid-operation serious-condition values floating-point-overflow short-float vector floating-point-underflow signed-byte warning
Figure 4--6: Standardized Type Specifier Names
While the object system is general enough to describe all standardized classes (including, for example, number, hash-table, and symbol), Figure 4--7 contains a list of classes that are especially relevant to understanding the object system.
built-in-class method-combination standard-object class standard-class structure-class generic-function standard-generic-function structure-object method standard-method
Figure 4--7: Object System Classes
A class @IGindex{class} is an object that determines the structure and behavior of a set of other objects, which are called its instances @IGindex{instance} .
A class can inherit structure and behavior from other classes. A class whose definition refers to other classes for the purpose of inheriting from them is said to be a subclass of each of those classes. The classes that are designated for purposes of inheritance are said to be superclasses of the inheriting class.
A class can have a name. The function class-name takes a class object and returns its name. The name of an anonymous class is nil. A symbol can name a class. The function find-class takes a symbol and returns the class that the symbol names. A class has a proper name if the name is a symbol and if the name of the class names that class. That is, a class~C has the proper name~S if S= (class-name C) and C= (find-class S). Notice that it is possible for (find-class S_1) = (find-class S_2) and S_1!= S_2. If C= (find-class S), we say that C is the class named S.
A class C_1 is a direct superclass @IGindex{direct superclass} of a class C_2 if C_2 explicitly designates C_1 as a superclass in its definition. In this case C_2 is a direct subclass @IGindex{direct subclass} of C_1. A class C_n is a superclass @IGindex{superclass} of a class C_1 if there exists a series of classes C_2,...,C_{n-1} such that C_{i+1} is a direct superclass of C_i for 1 <= i<n. In this case, C_1 is a subclass @IGindex{subclass} of C_n. A class is considered neither a superclass nor a subclass of itself. That is, if C_1 is a superclass of C_2, then C_1 != C_2. The set of classes consisting of some given class C along with all of its superclasses is called "C and its superclasses."
Each class has a class precedence list @IGindex{class precedence list} , which is a total ordering on the set of the given class and its superclasses. The total ordering is expressed as a list ordered from most specific to least specific. The class precedence list is used in several ways. In general, more specific classes can shadow @IGindex{shadow} _1 features that would otherwise be inherited from less specific classes. The method selection and combination process uses the class precedence list to order methods from most specific to least specific.
When a class is defined, the order in which its direct superclasses are mentioned in the defining form is important. Each class has a local precedence order @IGindex{local precedence order} , which is a list consisting of the class followed by its direct superclasses in the order mentioned in the defining form.
A class precedence list is always consistent with the local precedence order of each class in the list. The classes in each local precedence order appear within the class precedence list in the same order. If the local precedence orders are inconsistent with each other, no class precedence list can be constructed, and an error is signaled. The class precedence list and its computation is discussed in section Determining the Class Precedence List.
classes are organized into a directed acyclic graph. There are two distinguished classes, named t and standard-object. The class named t has no superclasses. It is a superclass of every class except itself. The class named standard-object is an instance of the class standard-class and is a superclass of every class that is an instance of the class standard-class except itself.
[Reviewer Note by Barmar: This or something like it needs to be said in the introduction.] There is a mapping from the object system class space into the type space. Many of the standard types specified in this document have a corresponding class that has the same name as the type. Some types do not have a corresponding class. The integration of the type and class systems is discussed in section Integrating Types and Classes.
Classes are represented by objects that are themselves instances of classes. The class of the class of an object is termed the metaclass @IGindex{metaclass} of that object. When no misinterpretation is possible, the term metaclass is used to refer to a class that has instances that are themselves classes. The metaclass determines the form of inheritance used by the classes that are its instances and the representation of the instances of those classes. The object system provides a default metaclass, standard-class, that is appropriate for most programs.
Except where otherwise specified, all classes mentioned in this standard are instances of the class standard-class, all generic functions are instances of the class standard-generic-function, and all methods are instances of the class standard-method.
The object system provides a number of predefined metaclasses. These include the classes standard-class, built-in-class, and structure-class:
The macro defclass is used to define a new named class.
The definition of a class includes: