Magic functions are APL functions internal to the interpreter. They are invoked by the interpreter in the current workspace whenever needed to perform a task that is easier to write in APL than in the native language of the interpreter (in the case of NARS2000, the native language is C).
For example, the Without function (L~R) is written as a magic function. To see the code used, type
¯2 ⎕cr '#DydTilde'
Z←L F R
Also, the Rank operator is a magic function:
¯2 ⎕cr '#DydRank'
Z←L (LO F Y) R;O
The next step is to expose this capability to the end user so she can write her own APL function (or group of functions) and associate them with a symbol or system name. Here's where the design work begins.
- I'd like to be able to combine multiple APL functions as a single magic function.
- I'd like a way to make the local vars to the magic function invisible to the normal system functions so the MF can reference global vars without fear of localization issues.
- There needs to be a way to associate the APL functions with a symbol (or system name) and to mark that symbol as a monadic/dyadic/ambivalent function/operator.
- There needs to be a way to call the previous meaning of the symbol/system name so as to allow overlays on top of existing symbols/system names.