Topic: APLX Help : Help on APL language : System Commands : )ERASE Erase names
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

)ERASE name(s)


Erases named global variables, functions, operators and classes from the active workspace. The command is followed by the name, or names, of the objects to be erased. If an item cannot be erased, a message to that effect is displayed. Local variables are not erased - use ⎕EX if you wish to do this.

             )ERASE ∆CC NEMO
       NOT FOUND: NEMO

Indirect erase

If one or more of the names following the )ERASE command is enclosed in parentheses and is the name of a variable which is a simple character scalar, vector or matrix, then the contents of the variable are interpreted as the name or names of items to be erased.

             )VARS
       A       B       C       DATA    MAT
             )ERASE A C
             )VARS
       B       DATA    MAT
             NAMES←⎕BOX 'B DATA'
             NAMES
       B
       DATA
             )ERASE (NAMES)      (rows of NAMES interpreted as object to erase)
             )VARS
       MAT     NAMES
             )ERASE NAMES
             )VARS
       MAT
             DATA←'A_NAME'
             )VARS
             DATA    MAT
             )ERASE (DATA)       (same error message as direct erase)
       NOT FOUND: A_NAME

Erasing individual class members

)ERASE can be used to erase a member (a method of property) from a class definition, using dot notation in the form ClassName.MemberName to specify which member should be deleted. The change will immediately be reflected in any existing instances of the class:

      PT←⎕NEW COLOR_POINT
      PT.⎕NL 2     ⍝ List properties of object PT
COLOR
X
Y
Z
      )ERASE COLOR_POINT.Z
      PT.⎕NL 2     ⍝ Object PT now has one less property
COLOR
X
Y

Erasing whole classes

)ERASE can also be used to erase a class definition (and all the methods and properties defined in it). Any instances of the class will become instances of the erased class's parent, if there is one, or of the NULL class, if the erased class did not have a parent. Similarly, any classes which inherited from the erased class will be re-parented so that they now inherit from the erased class's parent.

In this example, class POINT3D inherits from COLOR_POINT which in turn inherits from POINT. PT is an instance of COLOR_POINT:

      )CLASSES
COLOR_POINT    POINT   POINT3D
      ⎕CLASS POINT3D
{POINT3D} {COLOR_POINT} {POINT}
      PT←⎕NEW COLOR_POINT
      PT.⎕CLASSNAME
COLOR_POINT

If we erase the class COLOR_POINT, its child class POINT3D is re-parented. The instance PT becomes an instance of the original parent:

      )ERASE COLOR_POINT
      ⎕CLASS POINT3D
{POINT3D} {POINT}
      PT.⎕CLASSNAME
POINT

If we now erase the class POINT, POINT3D will now have no parent, and the instance PT becomes an instance of the NULL class:

      )ERASE POINT
      PT.⎕CLASSNAME
NULL
      ⎕CLASS POINT3D
{POINT3D}

Topic: APLX Help : Help on APL language : System Commands : )ERASE Erase names
[ Previous | Next | Contents | Index | APL Home ]