APLX Help : Help on APL language : System Functions & Variables : ⎕IC Insert into Class
|
|
![]() |
|
The dyadic system function Example: 'Point' ⎕IC ⎕BOX 'X Y MOVE' The left argument is a character vector containing the name of a new or existing class. If you specify a new class, it will be created. If you want the new class to inherit from an existing class, you can follow the class name by a colon and the name of the parent class. The right argument is a matrix of the names of the global functions, operators and variables which you want to insert into the class, padded to the right with blanks if necessary. If there is only one name, the right argument can be a character vector. If the right argument is an empty vector, the class will be created but no members will be inserted into it. The named items will be transferred into the class as follows:
Of course, you can alter the attributes of the members of the class later on by using the class editor, for example if you want to make one of the properties read-only. Note that the existing global definition of the inserted functions, operators and variables will be deleted, i.e. the operation moves rather than copies the items into the class. If the name corresponds to an existing member of the class, the existing member will be overwritten. The explicit result of In this example, we start with a workspace with a few variables and functions: Subject←'' Sender←'Charles Barker' Text←'' ∇Message B [1] Text←B [2] ∇ ∇R←Length [1] R←⍴Text [2] ∇ )FNS Length Message )VARS Sender Subject Text Now we insert all the existing functions and variables into a new class called Message. Note that the existing function Message becomes the Constructor of the new class: 'Message' ⎕IC ⎕NL 2 3 1 1 1 1 1 )FNS )VARS )CLASSES Message ⎕CR 'Message' Message { Text←'' Subject←'' Sender←'Charles Barker' ∇Message B Text←B ∇ ∇R←Length R←⍴Text ∇ } Message.⎕NL 2 ⍝ Public properties Sender Subject Text Message.⎕NL 3 ⍝ Public methods Length Message.⎕NL 10 ⍝ Constructor Message Finally, we create another class EMail which inherits from Message, and adds an extra uninitialized property Recipient: 'EMail:Message' ⎕IC 'Recipient' 1 ⎕CLASS EMail {EMail} {Message} )CLASSES EMail Message |
|
APLX Help : Help on APL language : System Functions & Variables : ⎕IC Insert into Class
|
Copyright © 1996-2010 MicroAPL Ltd