Chapter 9
Sealing
Overview
This chapter describes techniques for sealing portions of a Dylan program by declaring that classes or functions will never be used in particular ways, or will never be extended in particular ways. These sealing directives enable a range of compiler optimizations, and also clarify the programmer's intent.
The sealing directives include:
- Declaring a class to be
sealed
oropen
. This controls whether a class can be directly subclassed outside the library in which it is defined. - Declaring a class to be
abstract
orconcrete
. This controls whether a class can have direct instances. - Declaring a class to be
primary
orfree
. This controls how a class can be used for multiple inheritance. - Declaring a generic function to be
sealed
oropen
. This controls whether methods can be added to the generic function from outside the library in which the generic function is defined. - Using
define sealed domain
, or using the abbreviationsdefine sealed method
andsealed slot
. These disallow the addition of some methods from outside the library in which the generic function is defined.
With the exception of define sealed domain
, these directives are expressed
as adjectives on the generic function definition, class
definition, method definition, or slot specification.