Previous section: 8. Controlling Dynamism

Dylan reference manual -- Declaring characteristics of classes

Declaring characteristics of classes

A class definition (see the previous chapter on Classes) may include the adjectives sealed, open, primary, free, abstract, or concrete. These adjectives declare characteristics of the class.

* A class can be declared to be either sealed or open. If a class is sealed then no additional subclasses other than those explicitly defined in the same library may be created. Thus, it is an error to define a subclass of a sealed class in some library other than the one which defined the sealed class, or to use make of <class> with a sealed class directly or indirectly in the superclasses. An open class does not prohibit such operations. It is an error to define an open subclass of a sealed class.

When explicitly defining a class, the default is for the class to be sealed. This may be overriden by explicitly specifying that it is open. A class created using make of <class> is open. There is no specified way to create a sealed class using make.

* An explicitly defined class may be declared to be either primary or free. The default is free. It is illegal for a class to have two primary superclasses unless one is a subclass of the other.

* An explicitly defined class may be defined to be either abstract or concrete. The default is concrete. The superclasses of an abstract class must be abstract. An abstract class does not usually have slots; although defining slots in an abstract class is not forbidden, it should be done with caution, especially for instance allocated slots.

Next section: Declaring sealing of generic functions