Next: Instances, Previous: Introduction, Up: Top [Contents][Index]
A class is an object that determines the structure and behavior of
a set of other objects, which are called its instances. However,
in this document, the word instance usually means an instance of
the class <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 procedure class-name
takes a
class object and returns its name. The name of an anonymous class is
#f
.
A class C_1 is a 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 of C_1. A class C_n is a 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 all i between 1 and n. In this case, C_1 is a 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 is different from 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, 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 the most specific to the least specific. The class precedence list is used in several ways. In general, more specific classes can shadow, or override, 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, 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 signalled.
Classes are organized into a directed acyclic graph. There are
two distinguished classes, named <object>
and <instance>
.
The class named <object>
has no superclasses. It is a superclass
of every class except itself. The class named <instance>
is a
direct subclass of <object>
and is the base class for
instance objects. Instances are special because SOS has
efficient mechanisms for dispatching on them and for accessing their
slots.
• Class Datatype: | ||
• Predefined Classes: | ||
• Record Classes: | ||
• Specializers: |
Next: Instances, Previous: Introduction, Up: Top [Contents][Index]