home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol166 / lisp.rec < prev    next >
Encoding:
Text File  |  1984-04-29  |  7.6 KB  |  225 lines

  1.  
  2. {[LISP.REC]
  3. [REC object code from LISP source programs]
  4. [Harold V. McIntosh, 20 December 1980]
  5. [Harold V. McIntosh, 22 February 1981]
  6. [Harold V. McIntosh, 28 December 1983]
  7.  
  8. [30$ - input FCB]
  9. [31$ - output FCB]
  10.  
  11. [LISP is an invention of John McCarthy's dating from the late 1950's
  12.  at MIT.  LISP is based on Alonzo Church's lambda-calculus, and is
  13.  fundamentally recursive in nature.  It primarily manipulates text,
  14.  which leads to the idea of defining it in its own notation, after
  15.  the fashion of a Universal Turing Machine. The resulting Universal
  16.  function EVAL gives a self-consistent definition of LISP within LISP.]
  17.  
  18. [Unfortunately, for practical reasons as well as the influence of the
  19.  temperment of prospective users of LISP, pure recursion has proved 
  20.  to be very cumbersome for LISP.  To meet these objections, the "program
  21.  feature" was introduced into LISP.  The development of REC was a direct
  22.  consequence of the desire to design an aesthetic substitute for the
  23.  "program feature," having evolved from the related concept of "operator
  24.  predicates."]
  25.  
  26. [The fundamental reference to LISP is
  27.  
  28.         John McCarthy
  29.         "Recursve Functions of Symbolic Expressions
  30.             and their Computation by Machine"
  31.         Communications of the ACM 3 184-194 (1960),
  32.  
  33.   For a long time the only other reference was the user's manual,
  34.  
  35.         John McCarthy et al
  36.         LISP 1.5 Programmer's Manual
  37.         Computation Center and Research Laboratory for Electronics
  38.         Massachussets Institute of Technology
  39.         August 17, 1962.]
  40.  
  41. [An important aspect of LISP 1.5 and its successors as implemented at
  42.  MIT and elsewhere was the physical representation chosen for lists -
  43.  a binary tree with pointers to list elements and eventually constants
  44.  such as atoms and numbers. LISP.REC ignores this aspect entirely, so
  45.  that lists are chains whose parentheses are balanced anew with each
  46.  operation that is  carried out. This makes no difference whatsoever
  47.  in the linguistic aspects of the program, but of course renders it
  48.  entirely impractical for the execution of truly large programs. To
  49.  preserve the full aspects of LISP, it would only be necessary to make
  50.  a version of the primitive functions, read, and print, which would use
  51.  binary trees rather than chains.]
  52.  
  53. [The program implemented here is EVAL, not EVALQUOTE, APPLY, nor
  54.  another variant on the theme.  This means that one would present
  55.  as an example {cons {quote a} {quote {1 2 3}}} rather than the
  56.  version cons {a {1 2 3}} that EVALQUOTE would expect, or the
  57.  additional ALIST which which APPLY would require.]
  58.  
  59. [display w/cursor]        (248%I26%TLJZqt248%FD;;) D
  60.  
  61. [erase cursors]            (J(248%FD:JZ;);) E
  62.  
  63. [zero file control block]    ($m33cmpw0%(f:;)wnnS;) F
  64.  
  65. [create input, output FCB's]    ('5C'H12wA' 'Ew;B
  66.     [generate file names]     9aQpG'REC'|m (Z3b' 'E'LSP';Q;)|m w
  67.     [open input file]         n30$rS 30@f
  68.     [erase, open out file]     n31$rS 31@g31@e
  69.                 ;) G
  70.  
  71. [close file]            (
  72.     [clear workspace, in file]     @p:L@y:(@p:0=;e26%(f:;)@p;;)
  73.     [close file.REC]         31$r16k
  74.                  ;) H
  75.  
  76. [initialize]            (J@Wj@!;@!;) I
  77.  
  78. [read, with backspace]        (R26%='';T08%(=2080[sp,bs]TL)(@J|;L@J;);) J
  79.  
  80. [WS up to cursor to disk]    (jJ<(@p:L;)Zz>;) P
  81.  
  82. [compile a whole LISP file]    (Jj
  83.   [change file extension]      ('.LSP]'FD'.REC]'Iz;;)
  84.   [find display message]      ('[['F']]'UQD;'';)
  85.   [look for code gap]          ('('Ej;2573Ez2573Ez2573Ez2573Ej2bD;A:;)
  86.   [insert preface; to disk]      's'TL@s<'[[]]'FDIZ>z@P
  87.   [compile each function]      ('t'TL@tz@P'('Fj:;)
  88.   [insert postscript]          'u'TL@q@P
  89.                 ;) Q
  90.  
  91. [read, place in workspace]    (@$@::;) R
  92.  
  93. [15-line window]        (AB(10%Fz;Zz)qL
  94.                   15(d(10%FA;L(26%Fj;Z;)):;)Y<;<) W
  95.  
  96. [next unbalanced right p.]    (')'Ez;'('Ez@a:A:) a
  97. [find balancing parenthesis]    (A')'E;'('E@b::) b
  98. [insert required spaces]    (J('('FD' ('Iz:;)J(')'F' 'I:;);) c
  99.  
  100. [eliminate redundancies]    (J(09%FD:;)J(10%FD:;)J(13%FD:;)
  101.                  J('  'F' 'FD:;)J('( 'FADB:;)
  102.                  (J' )'F' 'FD:;);) d
  103.  
  104. [open file or create it]    (@h$r15K(255=22K;;)LL;) e
  105. [open file or report absence]    (@h$r15K(255='new file 'T;;)LL;) f
  106. [delete file if present]    (@h$r19k;) g
  107. [CP/M's DMA address]        ('80'H26k;) h
  108. [write one record]        (@Ej26%EZD0;128aqL26k31$r21kD'.'TL;) p
  109. [write LISP postscript]        (2573I'(@!@7@*@8;;)}'I;) q
  110.  
  111. [LISP subroutines]        (" {
  112.     [cr,lf]            (2573TL;)&
  113.     [console input]        (R13%='';T08%(=2080[sp,bs]TL)(@#|;L@#;);)#
  114.     [logon message]        ('[[]]'TL@&;)!
  115.     [bal paren]            (A')'E;'('E@+::)+
  116.     [next element]        (A'('E@+JA;j' 'U;')'U;)-
  117.     [enclose in quotes]        (JZD39%II39%IJQ;)%
  118.     [car]            (JZDI@-Q;)1
  119.     [cdr]            (JZDI@-D(' 'ED;;)JZQ;)2
  120.     [cons]            (JZD('()'='('II')'I;IAjI' 'I;)JZQ;)3
  121.     [atom]            (JZDI'('E'F';'T';)4
  122.     [eq]            (='T';L'F';)5
  123.     [null]            ('()'='T';L'F';)6
  124.     [read]            (@&'read> 'TL(@#;:);)7
  125.     [print]            (@&'      'TLT;)8
  126.     [append]            (JZDIjIzABBD' 'IJZQ;)9
  127.     [not]            ('T'='F';'F'='T';;)0
  128.                 "I;) s
  129.  
  130. [LISP function]            ('('FzABQD'('UDZ<@bJ><@c@dJ@u>
  131.                  ')'FD';)'II2573IJqt;>) t
  132.  
  133. [EVAL]                (
  134.                  ' 'ED:
  135.     [lambda]             '((lambda 'ED'('F')'UQQmDB
  136.                   '() 'EDZ<@bJQDn>')'E@w')'ED@x;
  137.     [primitive]             @v@w')'EDIz;
  138.     [quote]             '(quote 'ED34%I@aBD34%Iz;
  139.     [if]             '(if 'ED'('IzZ<@aBjJ><@u"'T'="
  140.                    Iz@u';L'Iz@u>';)'Iz')'ED;
  141.     [cond]             '(cond 'ED'('IzZ<@aBjJ><(ABj
  142.                    '('VDZ<@aBjJ><@u"'T'="Iz@u';L'I>
  143.                    z')'ED:;)>';)'Iz')'ED;
  144.     [and]             '(and)'ED"'T'"Iz;
  145.                  '(and 'ED'('IzZ<@aBjJ><(@u
  146.                    "'T'="IzAB:;)>"'T';;"Iz')'Ez;
  147.     [or]             '(or)'ED"'F'"Iz;
  148.                  '(or 'ED'('IzZ<@aBjJ><(@u
  149.                    "'T'='T';L"IzAB:;)>"'F';)"
  150.                    Iz')'ED;
  151.     [list]             '(list)'ED"'()'"Iz;
  152.                  '(list 'EDZ<@aBjJ><@z>z')'ED;
  153.     [atomic function name]     '('ED(' 'U;')'U;)Q@w')'ED'@'IIz;
  154.     [atom]             jABj(' 'U;Z;)'$ryG'Iz;
  155.                 ;) u
  156.  
  157. [REC code for LISP primitives]    ('(car 'E'@1';      '(cdr 'E'@2';
  158.                  '(cons 'E'@3';      '(atom 'E'@4';
  159.                  '(eq 'E'@5';      '(null 'E'@6';
  160.                  '(read)'E5a'@7'; '(print 'E'@8';
  161.                  '(caar 'E'@1@1'; '(cadr 'E'@2@1';
  162.                  '(cdar 'E'@1@2'; '(cddr 'E'@2@2';
  163.                  '(lp)'E3a'40%';  '(bl)'E3a'32%';
  164.                  '(rp)'E3a'41%';  '(tb)'E3a'09%';
  165.                  '(cr)'E3a'13%';  '(lf)'E3a'10%';
  166.                  '(append 'E'@9'; '(rec 'E'pC';
  167.                  '(not 'E'@0';    '(qu 'E'@%';
  168.                   ) v
  169.  
  170. [EVLIS]                (D(' 'ED:;)ABZ<@aBjJ><(@uzAB:;)>;;) w
  171.  
  172. [auxiliary to lambda]        (<I''m
  173.     [get variables]         (ABj(' 'UQD' 'ED;ZQD;)m:;)
  174.     [insert saves]         (n''=;pGI'$rmml'II'$S'I:)z>
  175.     [inner expression]         I@uz
  176.     [insert restores]         <I(ABj(' 'UQD' 'ED;ZQDz;)
  177.                  'nLn'II'$S'Iz:;)z>;) x
  178.  
  179. [append a record]        (128(e)L;qL26k30$r20K0=L;DLL@h) y
  180. [auxiliary to list]        (AB@u@z'@3'I;"'()'"I;) z
  181. [back to line feed]        (10%Ez;B:j;) 0
  182. [bracket a line]        (@010%V;Z;) 1
  183. [back to preceding line]    (@0BB@0;;) 2
  184. [cr,lf]                (2573TL;) &
  185. [read w/error correction]    (RT95%=127%;13%=2573;26%(=);) $
  186. [clear screen]            (26%TL;) !
  187. [erase on ro, insert others]    (127%=z(B;;)D;I;) :
  188. [form next window]        (Zz>@W@!;) >
  189. [cancel line]            (24%TL;) ^
  190.  
  191. (    'd' [delete] =        (ABD;;);
  192.     'i' [insert] =        (@D@$@::;)@!;
  193.     'j' [beginning] =    Jj;
  194.     'x' [exchange] =    (ABD;;)RTI;
  195.     'z' [to end] =        Z;
  196.     127%[delete] =        @1D@!;
  197.     10% [down arrow] =    (10%FA;J>(10%FA;;)@Wz@!;;);
  198.     13% [carr ret] =    @0;
  199.     11% [up arrow] =    (BA@2;J>@2@Wj@!;;);
  200.     08% [left arrow] =    (Bj;;);
  201.     'n' [next record] =    >(@p;L;)(@y;;)J(@W;;);
  202.     'p' [write 1 record] =    >(@p;L;)J(@W;;);
  203.     'y' [read 1 record] =    >(@y;'eof:'TL;)J(@W;;);
  204.     'Y' [read whole file] =    >(@y:;)J(@W;;)Jj;
  205.     ' ' [advance] =        (A;;);
  206.     '>' [next window] =    (@>j;>@I;);
  207.     '<' [beg window] =    >@I;
  208.     ',' [end of line] =    (2573Fj;Zz;)
  209.     '.' [refresh screen] =    @!;
  210.     's' [aux. functions] =    @s@!;
  211.     't' [cmpile 1 funct] =    >@t(@W;;)Jj@!;
  212.     ) ?
  213.  
  214. [main program]            (
  215.     [create FCB's, open files]      30@F 31@F @G
  216.     [sign-on]             'lisp.rec> 'TL
  217.     [automatic compilation]     ('5C'H12wAqt@&3b' 'E(w(@y:;)@Q@H;);w);
  218.     [wait, initialize, loop]     RTL @I (@DR
  219.     [exit at once]             ';'=@!;
  220.     [close, exit]             'e'=>@H;
  221.     [read menu]             @?:
  222.     [ignore unknown]         L:);)}
  223.  
  224. [end]
  225.