## ŚREPARENT Change parent of user-defined class

The dyadic system function ŚREPARENT allows you to change the parent of an internal (user-defined) class.

The left argument is a reference to the class which you want to re-parent (or a character vector containing the name of the class). The right argument is a reference to the class which will be the new parent (or a character vector containing the new parent's name).

Other than the restriction that the new parent class (the right argument) must not be descended from the class you are modifying (the left argument), there is nothing to prevent you from re-parenting a class arbitrarily. However, the main use for ŚREPARENT is for inserting an extra level into the class hierarchy. For example, if you have a class `Car` which inherits from `Vehicle`, you might want to create a new class `MotorVehicle` which inherits from `Vehicle`, and re-parent `Car` so that it now inherits from `MotorVehicle`:

          )CLASSES
    Car     MotorVehicle    Vehicle
          ŚCLASS Car
    {Car} {Vehicle}
          ŚCLASS MotorVehicle
    {MotorVehicle} {Vehicle}
          Car ŚREPARENT MotorVehicle
          ŚCLASS Car
    {Car} {MotorVehicle} {Vehicle}

The ŚREPARENT line above could alternatively be written as:

          'Car' ŚREPARENT 'MotorVehicle'

Any existing instances of the class will be unaffected except that any properties which are not valid in the new version of the class (because they were inherited from the old parent but are not inherited from the new parent) will be lost.

You can also re-parent a class using the `)REPARENT` system command, or by using the Class Editor (select Reparent Class.. from the File menu).

Topic: APLX Help : Help on APL language : System Functions & Variables : ŚREPARENT Change parent of user-defined class

[ Previous | Next | Contents | Index ]