Product Site

5.1.1.12. inherit

Causes the receiver class to inherit the instance and class methods of the class object classobj. The classpos is a class object that specifies the position of the new superclass in the list of superclasses. (You can use the superClasses method to return the immediate superclasses.)

The new superclass is inserted in the search order after the specified class. If the classpos class is not found in the set of superclasses, an error is raised. If you do not specify classpos, the new superclass is added to the end of the superclasses list.

Inherited methods can take precedence only over methods defined at or above the base class of the classobj in the class hierarchy. Any subsequent change to the instance methods of classobj takes immediate effect for all the classes that inherit from it.

The new superclass classobj must be created with the MIXINCLASS option of the ::CLASS directive or the mixinClass method and the base class of the classobj must be a direct superclass of the receiver object. The receiver must not already descend from classobj in the class hierarchy and vice versa.

The method search order of the receiver class after inherit is the same as before inherit, with the addition of classobj and its superclasses (if not already present).

Notes:
  1. You cannot change the classes that Rexx provides by sending inherit messages.
  2. The inherit method is a protected method.
Example 5.7. Class class — inherit method
room~inherit(.location)