Annotation of 43BSD/contrib/apl/doc/man.4, revision 1.1.1.1

1.1       root        1: .NH 1
                      2: Editing Functions
                      3: .PP
                      4: Function editing on
                      5: \*u \*a
                      6: differs from that on other
                      7: \*a systems.
                      8: The ``del'' character is not used.
                      9: Instead,
                     10: the \*u editor
                     11: is used.
                     12: There are two alternatives.
                     13: .PP
                     14: The ``)editf'' system command is
                     15: used to edit a function residing
                     16: in the internal workspace.
                     17: The command
                     18: .sp
                     19:        )editf fn
                     20: .sp
                     21: writes the function ``fn'' into
                     22: a temporary file and calls
                     23: the editor to process it.
                     24: When the editor is finished,
                     25: \*a reads it back in.
                     26: .PP
                     27: The command:
                     28: .sp
                     29:        )edit junk
                     30: .sp
                     31: invokes the editor to process
                     32: the \*u file ``junk''.
                     33: When the editor is terminated
                     34: via the ``q'' command,
                     35: control returns to \*a,
                     36: which will read ``junk'' into
                     37: the internal workspace.
                     38: Note that
                     39: this method involves files
                     40: external to \*a.
                     41: ``)editf'' is generally a better choice
                     42: since it allows all information relating
                     43: to the workspace to be contained
                     44: within the workspace.
                     45: .PP
                     46: Because of the way in which editing
                     47: is performed,
                     48: there are two points which need
                     49: special attention.
                     50: First,
                     51: it is not possible to edit a suspended
                     52: function.
                     53: (For a description of suspended functions
                     54: and how to reset them,
                     55: see ``The State Indicator''.)
                     56: Second,
                     57: if the function header
                     58: (first line of the function)
                     59: contains a syntax error,
                     60: \*a will
                     61: .I not
                     62: read in the function.
                     63: In general,
                     64: this means that the function
                     65: is no longer defined in the
                     66: workspace,
                     67: and the only other copy
                     68: exists in a temporary file.
                     69: In order to save you a lot
                     70: of work retyping,
                     71: \*a will
                     72: automatically copy the temporary
                     73: file into a file called
                     74: ``apl.badfn''
                     75: .PP
                     76: An example is probably called for at
                     77: this point
                     78: to clear the mud somewhat.
                     79: The following shows the creation
                     80: of the function ``fact''
                     81: which computes factorials
                     82: by multiplication.
                     83: .DS
                     84:        )editf fact
                     85:        [new fn]
                     86: XED
                     87: 0 lines
                     88: >a
                     89: [ 0 ]  n { fact+i
                     90: [ 1 ]    n { 1
                     91: [ 2 ]  loop: } (i = 0) / 0
                     92: [ 3 ]    n { n X i
                     93: [ 4 ]    i { i - 1
                     94: [ 5 ]    } loop
                     95: [ 6 ]  .
                     96: >w
                     97: >q
                     98: n { fact+i
                     99:       ^
                    100: syntax error
                    101: Function saved in apl.badfn
                    102: .DE
                    103: The error in line 0
                    104: (``fact+i'')
                    105: caused \*a to stop reading
                    106: the function,
                    107: so it was automatically copied
                    108: to the file ``apl.badfn''.
                    109: To get it back,
                    110: you can say:
                    111: .DS
                    112:        )editf fact
                    113:        [new fn]
                    114: XED
                    115: 0 lines
                    116: >r apl.badfn
                    117: 5 lines
                    118: >0s/+/ /p
                    119: [ 0 ]  n { fact i
                    120: >w
                    121: >q
                    122: .DE
                    123: .PP
                    124: If you use ``)edit'' instead of ``)editf'',
                    125: \*a will not worry about saving
                    126: the function in ``apl.badfn''
                    127: because you were editing from a
                    128: \*u file rather than
                    129: the internal workspace,
                    130: and that file still exists.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.