|
Dynamic inheritanceBecause parent slots are potentially assignable, we have a new concept in Self not present in class-based languages such as Smalltalk, C++ and Eiffel: dynamic inheritance.Using dynamic inheritance, an object can change one or more of its parents during execution. Typically, this is used when an object can be in one of a small number of discrete states, each having significantly different behavior from the others. An example is the object unix, which represents the Unix system call interface. It has a dynamic parent, currentOsVariant, which can be set to an object containing behavior specific to a particular variant of Unix; this is done every time the system is started. Dynamic inheritance should be used with caution: it is easy to construct programs which are very hard to understand!
|