home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / apl / ratapl / ratapl.doc < prev    next >
Text File  |  1989-03-15  |  30KB  |  742 lines

  1.  
  2.  
  3.                    Rationalized APL\PC Rel. T1.4
  4.  
  5.                           7 February 1989 
  6.  
  7.                        Network Distribution
  8.  
  9.  
  10.              (c) Copyright 1988, 1989 by NGARG, Zurich
  11.                         All rights reserved.
  12.  
  13.                          Author: A. Werder
  14.  
  15.  
  16. Rationalized APL\PC is an experimental APL interpreter model that 
  17. implements the concept of Rationalized APL and its successor 
  18. described in "A Dictionary of APL" by K.E. Iverson (APL Quote Quad,
  19. Volume 18, #1, ACM). Although it does not entirely implement all of 
  20. the Dictionary APL the interpreter provides the basic functionalities 
  21. of a future 3rd generation APL. 
  22.  
  23. DISCLAIMER:  This experimental software and documentation is 
  24.              provided on a "as is" basis with no warranty 
  25.              whatsoever.
  26.  
  27.              This product is provided as freeware; its use
  28.              for commercial advantage is strictly prohibited.
  29.  
  30.  
  31.  
  32.  
  33. 1. Installing the Interpreter
  34.  
  35. The requirements for running the Rationalized APL\PC interpreter 
  36. are: an IBM/PC-XT or AT (or compatible) with 640kB main memory, a 
  37. floppy disk (for the installation, if source is obtained from disk) 
  38. and a hard disk. Any PC/DOS release above 2.1 is acceptable. 
  39.  
  40.      
  41. PC Files for Interpreter
  42.  
  43. There are 3 files required for running the interpreter:
  44.  
  45.       RATAPL.EXE
  46.       RATAPL.SYS
  47.       PROLOG.ERR
  48.  
  49. The actual code which includes a minimal TurboProlog run time 
  50. system is contained in the file of type .EXE. The definitions for 
  51. the interpreter such as function and operator parts are contained 
  52. in the file RATAPL.SYS. This is in fact the prolog data base in 
  53. the form of an ASCII text file. The third file simply contains 
  54. error messages required for the TurboProlog run time system in 
  55. case of a failure. 
  56.  
  57. It is suggested that these files are installed in a suitable 
  58. directory; for example, C:\RATAPL. This documentation assumes
  59. that Rationalized APL\PC is installed in that directory.
  60.  
  61.  
  62. To start the Rationalized APL\PC, simply type <CD \RATAPL> and
  63. then <RATAPL>.
  64.  
  65. To see a short demonstration, start Rationalized APL\PC and 
  66. type <)load demo>.
  67.  
  68.  
  69. 2. Implementation Details
  70.  
  71. APL Keyboard and Display
  72.  
  73. The keyboard mapping for APL and ASCII characters is based on the 
  74. so called "union"-keyboard. The first alphabet is ASCII lowercase, 
  75. the second alphabet (normally APL underbarred characters) is upper 
  76. case. The APL characters can be generated by pressing ALT plus the 
  77. corresponding key. A number of APL characters and overstrikes can 
  78. be generated by pressing a key together with the CTRL-key. 
  79.  
  80. The four cursor keys as well as the <HOME>, <END>, <INS> and <DEL>
  81. key provide some simple editing facilities. In particular, cursor 
  82. <UP> recalls the previously entered line for re-editing.
  83.  
  84. TurboProlog resets the EGA character set to the default. 
  85. The supplied workspace "ega" may be used to load the APL character
  86. set. Type <)load ega> to load the EGA APL character set.
  87.  
  88.  
  89.  
  90. APL Variables: Limitations on Type, Rank and Size
  91.  
  92. Only the 4 basic data types "character", "integer", "real" and 
  93. "enclosed" have been implemented. For the purpose of internal 
  94. rationalization the data types "string" and "token list" have been 
  95. added. The rules for typing have been relaxed so that 
  96. heterogeneous arrays are now allowed. Arrays may be heterogeneous 
  97. in class and type. It is possible for instance to mix numbers and 
  98. functions. Class and type of an array are given by the class and 
  99. type of the first element in the array. Note that still most of 
  100. the primitives require homogeneous arguments. 
  101.  
  102. Boolean variables are represented as integers. Integers are 2 
  103. bytes long. Type coercion between integer and real normally occurs 
  104. if a scalar function is used. Some functions such as modulo or 
  105. binomial which use built-in TurboProlog predicates however do not 
  106. detect an integer overflow so that the result of such an operation 
  107. can lead to incorrect results. The absence of integer arithmetics 
  108. for real numbers in the underlying TurboProlog compiler 
  109. unfortunately also limits the domain of a number of functions (for 
  110. instance encode, decode etc.) to 2 byte-integers. 
  111.  
  112. Complex numbers are not implemented and consequently they neither 
  113. are within the argument domain of scalar functions. 
  114.  
  115. Infinity and negative infinity are represented by the symbol ² and 
  116. ²² respectively. Internally they are handled as big reals. Not all 
  117. scalar functions can handle them correctly and care should be 
  118. taken that no overflow occurs. 
  119.  
  120. In general the formatting facilities of the interpreter are very 
  121. limited. In particular the display of enclosed arrays is very 
  122. rudimentary. Also, in order to take advantage of the built-in 
  123. TurboProlog predicates, input and display of real numbers can 
  124. deviate from standard APL. 
  125.  
  126. The maxmimum rank of arrays has been fixed to 63, exceeding it 
  127. will lead to a <limit error>. Since the data part of APL variables 
  128. is always represented in a list of data elements and those lists 
  129. are processed within the interpreter in recursive predicates the 
  130. amount of stack memory required is considerable. Variables with 
  131. more than 500 elements almost always lead to problems with the 
  132. stack and should be avoided. 
  133.  
  134. Note:  If a behaviour of the interpreter is said to be problematic 
  135.        this means that in case of a failure the Rationalized APL\PC 
  136.        interpreter will terminate with an error message (in the 
  137.        lucky case) but it may also cause the PC to hang (in the 
  138.        unlucky case). In such a situation the active workspace
  139.        is definitely lost. Frequent )save of the workspace can 
  140.        save the user from loss of valuable data.
  141.  
  142. Some work has been done in order to make the interpreter safer. In 
  143. particular, stack overflow should now be reported as workspace full 
  144. error (due to some problems with the compiler's error trapping 
  145. feature errors other than ws full may also occur though). The use of 
  146. TurboProlog version 2.0 compiler has helped to sort out some 
  147. problems. Yet the interpreter is still not 100% reliable... 
  148.  
  149.  
  150. Active and Saved Workspaces
  151.  
  152. The user's workspace is kept in the interpreter's (Prolog-) data 
  153. base. The workspace which mainly consists of the symbol table is 
  154. read and written every time the user is prompted in immediate 
  155. execution mode. If a user defined function is called, a new local 
  156. symbol table is set up that also contains the global environment. 
  157. Upon completion of a function the local environment is dissolved 
  158. and the previous more global environment is re-established. Global 
  159. objects are not kept within the symbol table functor. They are 
  160. stored as separate objects in the data base. 
  161.  
  162. This mechanism is very slow and limits considerably the use of 
  163. user defined (in particular recursive) functions. Defined 
  164. functions consisting only of one line are special cased and run a 
  165. bit faster. 
  166.  
  167. Saved workspaces are unloaded versions of the relevant parts of 
  168. the data base. It is not guaranteed that saved workspaces are 
  169. compatible with future releases of the Rationalized APL\PC. 
  170. Workspaces saved under release T1.0 are not compatible with this 
  171. release. 
  172.  
  173.  
  174. Function and Operator Parts
  175.  
  176. The definition of functions and operators (the basic function and 
  177. operator parts) are also taken from the interpreter's data base. 
  178. This data base is initially set up at program start (this is done 
  179. with a <consult> of the file <RATAPL.SYS>).   
  180.  
  181. Provided the experimentor is familiar with the internals of the 
  182. Rationalized APL\PC and has some knowledge of TurboProlog, it is 
  183. possible to change such parts in order to vary the behaviour of 
  184. the interpreter or some part of it. Such changes however should be 
  185. made with extreme caution. A set of files for maintaining the part 
  186. definitions is available separately from the author.
  187.  
  188. Parsing rules are not defined dynamically through the data base. 
  189. For reasons of speed they have been coded into the interpreter. 
  190. Modifying those syntax rules is therefore not possible. 
  191.  
  192.  
  193.  
  194. 3. Functionalities of the Rationalized APL\PC 
  195.  
  196. The Rationalized APL Syntax
  197.  
  198. The Rationalized APL\PC interpreter is based on the Rationalized APL 
  199. syntax. The syntax rules have been been slightly modified however.
  200. Functions derived from a monadic operator which evaluate to class 
  201. data (for instance from a functional enclose operator) do not 
  202. require an additional pair of parentheses (thus allowing the 
  203. expression f+$, -$ if $ is the functional enclose operator). 
  204.  
  205. The current version implements most of the APL primitives listed in 
  206. "A Dictionary of APL". Note that the assignment of symbols to 
  207. primitives deviates in a few cases from the APL Dictionary. 
  208.  
  209.  
  210. Available Primitive Functions
  211.  
  212.     +   identity     plus       0 0 0
  213.     -   negative     minus      0 0 0
  214.     Æ   sign         times      0 0 0
  215.     ÷   reciprocal   divide     0 0 0
  216.     *   exponential  power      0 0 0
  217.        natural log  log        0 0 0
  218.     ì   ceiling      maximum    0 0 0
  219.     Å   floor        minimum    0 0 0
  220.     ■   magnitude    absolute   0 0 0
  221.     !   factorial    binomial   0 0 0
  222.     ?   roll         deal       0 0 0     not implemented
  223.     ~   not          difference 0 0 0     difference not implemented
  224.     ^                and          0 0     lcm not implemented
  225.     ·                or           0 0     gcd not implemented
  226.     Ω                nand         0 0      
  227.     σ                nor          0 0      
  228.     =                equal        0 0
  229.     å                not equal    0 0
  230.     <   enclose      less       ² 0 0
  231.     >   disclose     greater    0 0 0
  232.     ≥                not less     0 0
  233.     ≤                not greater  0 0
  234.     ∙   Pi times     circle     0 0 0     circle functions: αε1 2 3 ²3
  235.  
  236.     Γ   index gen.   index of   ² 1 ²    
  237.     ,   ravel        catenate   ² ² ²
  238.     ₧   ravel        catenate   ² ² ²     functions along first axis
  239.        weak enclose link       ² ² ²
  240.        pass         dex        ² ² ²
  241.        stop         lev        ² ² ²
  242.     √   shape        reshape    ² 1 ²
  243.        nub          take       ² 1 ²
  244.        raze         drop       ² 1 ²
  245.     {   cart.prod.   from       ² 0 ²
  246.                                           no complementary indexing
  247.     φ   transpose    transpose  ² 1 ²     dyadic transpose: α≡α
  248.     Φ   reverse      rotate     1 0 1
  249.     Θ   reverse      rotate     ² ² ²     reverse along first axis
  250.     ε                member       0 ²
  251.     τ                encode       ² ²     en- and decode: 2-Byte integers
  252.     µ   tokenise     decode     1 ² ²     only; tokenise not implemented
  253.        grade        grade      ² 1 ²     no secondary ordering
  254.        gradedown    gradedown  ² 1 ²     no secondary ordering
  255.     ÿ   mat.inverse  mat.divide 2 ² 2     not implemented
  256.     ≡                match        ² ²
  257.     ⌠   format       format     ² ² ²     very limited implementation
  258.     ⌡   execute      execute    1 1 1     extended result range
  259.                     I-beam       ² ²     system functions
  260.  
  261.  
  262. Operators
  263.   
  264.     f/    reduction                  derived function: monadic only
  265.     fδ    reduction along 1st axis   derived function: monadic only
  266.     f\    scan                       
  267.     fº    scan along 1st axis        
  268.     α/    compress
  269.     fδ    compress along 1st axis
  270.     f\    expand                     not implemented
  271.     fº    expand along 1st axis      not implemented
  272.     f     swap                        
  273.     f}    select, merge              monadic form not implemented
  274.     f[    yoke always
  275.     f]    yoke conditionally         experimental
  276.  
  277.     α.f   tie, outer product         forces fπ0; α: ° treated as 0
  278.     f.g   inner product              derived function: dyadic only
  279.     f.α   power                      not implemented
  280.     fπα   set function rank
  281.     fπg   on (function composition)
  282.     απf   cut                        not implemented
  283.     αf   glue
  284.     fα   glue
  285.     fg   with (function composition)
  286.     αΣf   prefer                     ~α≡α
  287.     fΣα   defer                      ~α≡α
  288.     fΣg   upon (function composition)
  289.     fh[g  yoke always
  290.     fh]g  yoke conditionally (recursion operator)
  291.  
  292.     α∞   direct definition
  293.     f∞g   function application
  294.     α∞f   class definition           αε4 5
  295.  
  296.  
  297. Derived Functions
  298.  
  299. Functions can be recursively derived and there is virtually no 
  300. limitation on the depth of recursion (except the interpreter's 
  301. stack area). Some examples might illustrate the power of such 
  302. recursions: 
  303.  
  304.       (,π2)Σ1   Ravel rank-2 cells after deferring axis
  305.       +.Æδ      Reduction on inner product 
  306.       +/Σ2      Reduction along axis 2
  307.       ₧>/      The raze function
  308.       ⌡Σ(0{)   Execute after selection
  309.  
  310. Internally a number of derived functions are used to implement 
  311. functions of high complexitiy with combinations of functions of 
  312. less complexity. For instance, the cartesian product has been 
  313. implemented as the derived function
  314.  
  315.       >Σ(0.(,>)>/Σ(<π0>))
  316.  
  317. Again, the complexity of the definition restricts the domain of the 
  318. arguments to relatively small arrays in such cases. 
  319.  
  320. User defined functions can also be derived: 
  321.  
  322.       ('+' ∞ 'α+')π0
  323.  
  324. With the exception functions derived from the del-operator the 
  325. execution of derived functions is deferred until they are actually 
  326. evaluated. The vector representation of derived functions for 
  327. displays corresponds to the constituting APL expression after 
  328. names have been replaced by their values. 
  329.  
  330.  
  331. Function Rank
  332.  
  333. The RATAPL.SYS file delivered with the interpreter defines some 
  334. default function ranks different from the APL Dictionary. For 
  335. instance an expression like Γ2 3 results in a rank error. Using
  336. the function rank operator explicitly will produce a result rather 
  337. than an error message:
  338.  
  339.       Γπ(0) 2 3 
  340. 0 1 0
  341. 0 1 2
  342.  
  343. A modification of the RATAPL.SYS file can change the behaviour to 
  344. conform with the Dictionary.
  345.  
  346.  
  347. Function Definition
  348.     
  349. Functions may be defined using the function definition operator 
  350. (del): 
  351.  
  352.       plus '+' ∞ 'α+'
  353.       fac  ('(≤1){1 2'  'Ʊ -1'  '1') ∞ °
  354.  
  355. The operator always requires both definitions, the monadic and the 
  356. dyadic. The arguments may be a character array of rank>2 or an 
  357. enclosed vector of character arrays of rank<2. Instead of an empty 
  358. character vector the jot (°) can be used to designate a non 
  359. existing case of a definition. Execution of an undefined case is 
  360. identical to the execution of the identity function. 
  361.  
  362. The following rules apply within the function definition: 
  363.  
  364.   - The symbol α denotes the optional left,  the right argument.
  365.   - The result of the last line executed is propagated as the 
  366.     function's overall result.
  367.   - Branching is done with  (the interpreter replaces the goto by 
  368.     an assignment to òlc).
  369.   - If a branch is done with an vector of line numbers then those 
  370.     lines are executed in the corresponding order.
  371.   - The function terminates upon exhaustion of òlc or if an 
  372.     invalid line number is detected.
  373.   - Self reference of a function is achieved with the symbol ±.
  374.   - One line functions should not begin with a branch.
  375.  
  376. Resuming a suspended function is not possible. A naked branch 
  377. usually pops up one level and so allows to escape from it. Note 
  378. that a naked branch in immediate execution mode on the top level 
  379. causes the interpreter to terminate normally: the next level is 
  380. PC/DOS. 
  381.  
  382. Defined functions functionally behave like primitive and derived 
  383. functions. In particular they may appear as arguments to operators 
  384. (for instance in inner products; likewise the argument rank of a 
  385. defined function may be set with the rank operator). 
  386.  
  387. Defined functions build up a new level in the state indicator 
  388. stack and provide a new environment for local variables. This 
  389. process is unfortunately is extremely slow so that the execution 
  390. defined functions is quite limited. 
  391.  
  392.  
  393. Defined Operators
  394.  
  395. The del-hyper operator may be used for changing the object class. 
  396. With a left argument of 4 the operator turns a function 
  397. (primitive, derived or defined) into a monadic operator. A left 
  398. argument of 5 turns it into a dyadic operator. 
  399.  
  400.     4 ∞ f       Change class of f from function to monadic operator
  401.     5 ∞ f       Change class of f from function to dyadic operator
  402.  
  403. Examples:
  404.  
  405.     fenc 4 ∞ <            ª functional enclose
  406.     each 4 ∞ ('>'∞°)    ª each operator 
  407.  
  408.     ª Hodgkinson's if-else construct (Hodgkinson, 1987)
  409.     if   5 ∞ (°∞'>(å0){(<∞),(<∞α)') 
  410.     else 5 ∞ (°∞'>((<∞α)≡(<∞)){(<∞α),(<∞)') 
  411.     + if (n>0) else -      ª conditionally select a function
  412.  
  413.  
  414. The Yoke-Operators
  415.  
  416. The current release includes the definitions for two new monadic 
  417. operators: Yoke always and yoke conditionally. Yoke always conforms to 
  418. the definitions given in the Dictionary of APL. Both accept a (dyadic) 
  419. function argument. The derived form however is not of class function but 
  420. of class dyadic operator. The derived dyadic operators accept a left and 
  421. right operator argument of class function. Both yoke operators perform 
  422. function composition except that they combine three functions instead of 
  423. two like their known counterparts (for instance Σ). The definition is the 
  424. following:
  425.  
  426.     kf h[ g    yoke always: 
  427.                 k(x,y):   h(f(x,y), g(x,y))
  428.                   k(x):   h(f(x), g(x))
  429.     kf h] g    yoke conditionally:
  430.                 k(x,y):   f(x,y)å0:   h(x, k(x, g(x,y)))
  431.                           f(x,y)=0:   h(x, g(x,y))
  432.                   k(x):     f(x)å0:   h(x, k(g(x)))
  433.                             f(x)=0:   h(x, g(x))
  434.  
  435. As can be seen from the definiton, the conditional yoke applies the 
  436. derived function recursively until a condition expression (identified by 
  437. the left derived operator argument f) evaluates to 0. A final function 
  438. composition on h and g terminates the recursion.
  439.  
  440. The faculty function fac: Æfac -1: ≤1 : 1 could be written as
  441.  
  442.       fac 1< Æ] (1ìΣ(-1))
  443.  
  444. whereas the more complex
  445.  
  446.       scan4 ∞ ('1<Σ√(₧[(δ))](²1)' ∞ °)
  447.  
  448. provides an alternative definition of the monadic scan-first operator. 
  449.  
  450. The use of the simpler variant yoke always is more obvious. This can 
  451. be shown by a few examples: 
  452.  
  453.       sort  {[          ª apply from on the results of grade 
  454.                              and identity 
  455.  
  456.       ª an alternative form of the average function
  457.       sum+/  shape√  dividedBy÷
  458.       avg sum dividedBy[ shape
  459.  
  460.  
  461. System Constants, Variables and Functions
  462.  
  463. The only system constant ° is an undisclosable scalar.
  464.  
  465. System variables which are a part of the workspace environment are 
  466. available but not fully implemented. With the exception of the 
  467. variables òapl and òdbg, the system variables (òio, òrl, òct, òpp, 
  468. òps, òpw) can be referenced but assigning a value to them has no 
  469. influence (note that for instance òio is always 0 and cannot be 
  470. changed). System variables can be localised on every new SI stack 
  471. level.
  472.  
  473.     òapl        APL dialect (initially 0); 0 forces the interpreter
  474.                 to use Rationalized APL rules, 1 forces AIDA rules
  475.                 (see Gfeller 86).
  476.  
  477.     òav         Atomic vector; this system variable is available
  478.                 (Note: display of 0{òav causes subsequent 
  479.                 characters to be discarded).
  480.  
  481.     òio         Index origin (always 0). The index origin cannot 
  482.                 be varied.
  483.  
  484.     òct         Comparison tolerance (always 0). The concept of 
  485.                 comparison tolerance and fuzzy functions is not 
  486.                 implemented, however the variable is available.
  487.  
  488.     òdbg        Debugging mode (initially 0). This variable can be 
  489.                 used to inspect the behaviour of the interpreter 
  490.                 during syntax parsing and operator and function 
  491.                 execution. It acceptes the following values:
  492.  
  493.                 1 - Syntax parsing, display of tokens in left and 
  494.                     right stack (see APL Dictionary).
  495.                 2 - Same as 1 but display of full internal 
  496.                     representation of tokens in right stack.                   
  497.                 3 - Same as 2 plus additional display of operator 
  498.                     execution stack during evaluation phase.
  499.  
  500.     òlc         Line counter; the line counter can be set with the 
  501.                 branch (). Only the top level of the state 
  502.                 indicator is reported. The result is always an 
  503.                 integer vector of line numbers (or empty).
  504.  
  505.     òpp, òps,   System variables that normally govern the 
  506.     òpw, òfc    formatting during output. These system variables 
  507.                 are not used for this purpose, they are only 
  508.                 available for completeness.
  509.  
  510.     òrl         Random link; not implemented.
  511.  
  512.     ò, ù        Quad, quote-quad; quad is only defined for output, 
  513.                 quote-quad only for input.
  514.  
  515.  
  516.  
  517. System Functions
  518.  
  519.     òai         Result is a 3-element vector and which reports the 
  520.                 user identification and the elapsed time since the 
  521.                 program start (the 3rd element is unused). 
  522.  
  523.     òcr        Canonical representation (monadic argument rank 1); 
  524.                 returns the canonical representation of user 
  525.                 defined functions. The result is a two element 
  526.                 enclosed array with the first element containing 
  527.                 the monadic and the second containing the dyadic 
  528.                 definition of .
  529.  
  530.     òcmd       DOS command interface. Executes the DOS command 
  531.                 passed in  and restores APL environment upon 
  532.                 completion.
  533.  
  534.     òedit      Edit vector of enclosed character vectors using 
  535.                 TurboPrologs built in editor.
  536.  
  537.     òex        Expunge object (monadic argument rank: 1); removes 
  538.                 the most local value bound to name  from the 
  539.                 symbol table.
  540.  
  541.     ònc        Name class (monadic argument rank: 1); reports 
  542.                 the class of a named object. The result is an 
  543.                 integer array of rank and shape depending on the 
  544.                 rank and shape of the argument. The classes are 
  545.                 assigned as follows:
  546.  
  547.                 0 - Invalid name
  548.                 2 - Variable
  549.                 3 - Function
  550.                 4 - Monadic operator
  551.                 5 - Dyadic operator
  552.  
  553.     ònl        Name list (monadic argument rank: 0); returns a 
  554.                 list of all objects of class  in the form of a 
  555.                 character matrix. Note that ²1 denotes all 
  556.                 classes.
  557.  
  558.     òsa         Storage area; reports the available free stack, 
  559.                 heap and tail area in bytes.
  560.  
  561.     òts         System time stamp in the form of a 7-element 
  562.                 integer vector (year, month, day, hour, minute, 
  563.                 second, second/100).
  564.  
  565.     òwa         Work area; reports the available free heap area in 
  566.                 bytes (same as 1{òsa).
  567.  
  568. For the purpose of internal design rationalization the I-beam 
  569. primitive has been implemented to provide a further number of system 
  570. functions. The following functions are available: 
  571.  
  572.      0        Convert string or token list to character vector
  573.      6        Convert character vector to string scalar
  574.      8        Tokenise string; result is a token list
  575.  
  576.     20        Edit string vector in current window
  577.     21        Switch or define new window on screen
  578.                 √√  0:    switch to window  (must be defined)
  579.                 √   7:    define window [0] with attributes
  580.                              [1 2] and an offset and size of 3
  581.     220        Resize the currently active window
  582.     23        Resize the screen (EGA/VGA cards only)
  583.                 0{  rows, 1{  columns
  584.     24        Display a menu  in current window and return
  585.                 the selected row index (where  is a string variable;
  586.                 for matrices, use the expression: 246π><π1 )
  587.  
  588. To edit an array (an enclosed  vector of character vectors for 
  589. instance) the composed edit function can be used (in fact the 
  590. system function òedit is defined the same way): 
  591.  
  592.       edit0>Σ(20Σ(6π>))
  593.       aedit 'try this''example''for editing'
  594.  
  595. Since the built-in TurboProlog editor is invoked APL characters can 
  596. not be typed in. They are displayed however and can be composed with 
  597. the proper ALT-number sequence.
  598.  
  599.  
  600. System Commands
  601.  
  602. System commands are implemented in a very rudimentary form. Among 
  603. the available commands, load and save are probably the most useful 
  604. commands. 
  605.  
  606.     )clear      Clear workspace; only to be executed on the root 
  607.                 level of the SI stack.
  608.     )load       Load Rationalized APL\PC workspace
  609.     )off        Leave Rationalized APL\PC (the same effect can be 
  610.                 achieved with a naked branch on the top immediate 
  611.                 execution level).
  612.     )save       Save Rationalized APL\PC workspace
  613.     )si         Display state indicator; note that an immediate 
  614.                 execution level is always reported separately and 
  615.                 that since defined functions and operators are always 
  616.                 unnamed no names are displayed.
  617.     )wsid       Display or set name of the active workspace.
  618.  
  619. Workspaces are saved in the form of a TurboProlog data base. They 
  620. are ordinary ASCII text files containing only a few predicates 
  621. (workspace information, state indicator and global values). 
  622. Changing the content of such a file outside of Rationalized APL\PC 
  623. can cause a message "workspace incompatible" at the next load. 
  624.  
  625.  
  626. Assignment
  627.  
  628. Direct and indirect assignment is supported. Direct assignment can 
  629. be local or global. 
  630.  
  631. If the assignment arrow is preceded by a space then the variable 
  632. is assigned a global scope. Otherwise the variable will have local 
  633. scope. 
  634.  
  635.       aΓ10               ª a local variable
  636.       fenc 4∞<           ª a global operator
  637.  
  638. Note that within defined functions variables are always assumed to 
  639. be global until they are assigned a value locally. In the example 
  640.  
  641.       inc('+AA+1' ∞ °)
  642.  
  643. the first occurrence of A from right binds the value of the global 
  644. variable A and assigns it (after having it incremented) to a local 
  645. variable named A. The global variable A remains unchanged if the 
  646. function inc is executed. 
  647.  
  648. Indirect assignment is achieved with an expression within 
  649. parentheses to the left of the assignment arrow. If the expression
  650. evaluates to an enclosed array then multiple assignment is 
  651. provided. In that case the outer frames of the expressions to the 
  652. left and the right of the assignment arrow must correspond.
  653.  
  654.       ('jan''feb''mar') φqtr881    ª assign each column 
  655.                                       ª individually
  656.       (<> 'plus''a') ⌡>'+''100'  ª mixed class assigment
  657.  
  658. If the expression on the left of the assigment arrow contains 
  659. recursively enclosed elements then the corresponding cells are 
  660. disclosed prior to the assigment.
  661.  
  662.  
  663.  
  664. 4. Miscellanous Functionalities
  665.   
  666. Non-data Arrays
  667.  
  668. The interpreter allows the construction of non-data arrays. 
  669. Currently only function arrays are implemented. The simplest 
  670. method the create a function arrays is to use the execute function 
  671. with an argument of rank grater than 1:
  672.  
  673.       ⌡π(0) 2 2 √'+-Æ÷'         ª 2 by 2 function matrix
  674.  
  675. Refer to Werder 1988 for more details. Function arrays may 
  676. be applied to data arrays in a similar way as proposed by 
  677. Bernecky (Bernecky 84): 
  678.  
  679.       2 far 4                   ª note the scalar extension
  680. 6   ²2       
  681. 8    0.5
  682.       (⌡π0 'Φ') 2 3√Γ6 
  683. 2 1 0
  684. 3 4 5
  685.  
  686. In the current implementation the shape of the outer frame 
  687. resulting from applying the function rank must conform with 
  688. the shape of the function array (unless the function array is
  689. a scalar in which case scalar extension applies). The function
  690. array's function rank is derived from the first function.
  691. Uniformity in function ranks is not required for the array.
  692.  
  693.  
  694. APL Language Dialects
  695.  
  696. In a clear workspace, the system variable òapl is set to 0. This 
  697. causes the interpreter to use normal Rationalized APL rules for 
  698. syntax parsing. If the variable òapl is set to 1 the interpreter is 
  699. forced to use the parsing rules of the APL incompatible dialect 
  700. AIDA (see Gfeller 1986 for details). Note that only the syntax is 
  701. changed, and no additional functionalities are provided. 
  702.  
  703.       òapl1
  704.       (/+) (Γ10) 
  705. 45
  706.       5√+,-
  707. + - + - +
  708.  
  709. Since de-tokenisation is always based on òapl0 displaying 
  710. for instance the derived function (/+) results in the normal
  711. order +/. 
  712.  
  713. Note that no other value except 0 or 1 should ever be assigned to 
  714. òapl. A value different from 0 or 1 forces the interpreter to use 
  715. inexistant parsing rules - and therefore results always in an 
  716. undefined syntax. 
  717.  
  718.  
  719.  
  720. 5. References
  721.  
  722. Gfeller 86
  723. Gfeller, Martin: Operators considered harmful, APL Quote 
  724. Quad, Vol. 17, No. 1, September 1986 
  725.  
  726. Hodgkinson 87
  727. Hodgkinson, Robert: Practical Uses of Operators in SHARP 
  728. APL/HP, APL 87 Conference Proceedings, Dallas, May 1987
  729.  
  730. Iverson 83
  731. Iverson, K.E.: Rationalized APL, I.P. Sharp Research 
  732. Report #1, Toronto, April 1983 
  733.  
  734. Iverson 87
  735. Iverson, K.E.: A Dictionary of APL, I.P. Sharp Associates, 
  736. Toronto, March 1987 
  737.  
  738. Werder 88
  739. Werder, A.: Arrays of Objects in Rationalized APL, 
  740. APL 88 Conference Proceedings, Sydney, February 1988
  741.  
  742.