Friday, December 16, 2005

Layers of Implementation

APyL2 can be implemented in several layers:


  1. AplArray class with fundamental array structure and behavior
  2. primitive functions that act on AplArray objects
  3. primitive operators that act on functions and AplArrays
  4. symbol name to function name translation functions
  5. APL2 input parser
  6. APL2 character set and interpreter environment


The AplArray class should convert conventional data structures (Python primitives or a Python list) and save the data in a format with characteristics of an APL array. The AplArray should have two Python lists containing the shape of the array and the data in the array. AplArray should also have a basic assignment function which populates the shape and data lists.

The second layer is a set of functions that implements APL2 primitive functions. In IBM's APL2 Programming: Language Reference, Appendix A, there is a table of symbols, symbol names, and function names. These function names can serve as the APyL2 function names. All of these functions will take one or two AplArrays as input parameters and all of them will return either nothing or an AplArray. Examples of function names are Shape, Interval, and Ravel.

The only complicating factor in implementing primitive functions is functions with Axis specification. Axis specification may be an optional input (with an appropriate default set in the function call) for these special functions.

I'm not familiar enough with primitive operators to have a clear idea of how to implement them. My general idea is that primitive operators should be implemented as Python functions which accept primitive functions and arrays as input.

Most APL programmers will recognize symbol names more easily than function names. For example, the symbol name "iota" is easier to remember than the function names "Interval" or "Index Of", which are represented by the iota symbol. Thus, it will be useful to have a symbol name to function name translator that allows the users to call functions by their symbol name rather than by function name. The symbol name to function name translater functions will take one or two AplArrays as input, then pass them to the corresponding monadic or dyadic function associated with that symbol.

The final layer is the APL2 interpreter environment and character set. This is really a user interface layer. All functions, operators, and symbol names can be called by their Python function names in the Python environment. For a complete APL2 experience, however, the APL2 interpreter environment is a necessity.

0 Comments:

Post a Comment

<< Home