Topic: APLX Help : Help on APL language : System Commands : )REPARENT Reparent class
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

)REPARENT class parent


)REPARENT allows you to change the parent of an internal (user-defined) class.

The first argument is the name of the class which you want to re-parent. The second is the name of the class which will be the new parent.

Other than the restriction that the new parent class must not be descended from the class you are modifying, 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}
      )REPARENT Car MotorVehicle  
      ⎕CLASS Car
{Car} {MotorVehicle} {Vehicle}

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 function, or by using the Class Editor (select Reparent Class.. from the File menu).


Topic: APLX Help : Help on APL language : System Commands : )REPARENT Reparent class
[ Previous | Next | Contents | Index | APL Home ]