| Calling Sequence
| ExtendClass(newclass,oldclass,addarg1,...)
|
| Parameters
| | Name | Type | Description |
|
| newclass
| symbol | The new class, oldclass with more fields |
| oldclass
| symbol | The base class being extended |
| addarg1
| [symbol, type, anything] | Description of additional arguments |
|
| Return Type
| NULL |
| Synopsis
| ExtendClass creates a new class which has all
the fields of the base class plus additionally defined ones.
The result is a new class which automatically inherits all
the methods of the oldclass and has additional fields
described in the 3 and onwards arguments of ExtendClass.
The description of each additional argument is a list of
three values, the name of the new field, its type and,
optionally, its default value. The default value is used
when creating an object without it or when converting an
object from oldclass to newclass. More precisely the following
functions are created: |
| |
|
| | Old method | New Method | Comment |
|
| oldclass | newclass | Constructor based on the oldclass constructor |
| oldclass_xxx | newclass_xxx | same rules as Inherit |
| yyy_oldclass | yyy_newclass | conversions from other classes to newclass |
| | oldclass_newclass | widening conversion |
| | newclass_oldclass | narrowing conversion |
|
| |
|
| If some methods are not expected to be inherited
from oldclass, they should either be unevaluated after calling
ExtendClass or defined before calling ExtendClass.
|
| ExtendClass does an implicit Inherit, so there is
no point in doing an Inherit(newclass,oldclass). Any protection
defined for the oldclass is inherited in the newclass. The newclass
can Inherit other additional classes as usual.
|
| Examples
| > ExtendClass( DistTree, Tree, [height,numeric,0] );
|
| See also
| CompleteClass, Inherit, objectorientation, Protect |