Minor formatting change in section 3.2.1.2.
[mudman.git] / md / environment.md
1 % The Muddle Programming Environment
2 % P. David Lebling
3 % May 1980
4
5 MIT Technical Report 294
6
7 Laboratory for Computer Science  
8 Massachusetts Institute of Technology  
9 545 Technology Square  
10 Cambridge, Massachusetts 02139
11
12 # Copyright
13
14 This book was originally published in the United States in 1980
15 without a copyright notice and without subsequent registration with
16 the U.S. Copyright Office within 5 years. Doing at least one of those
17 was a requirement of United States copyright law at that time [^1].
18 This book is therefore in the public domain in the United States for
19 failure to comply with the required formalities. This means you're
20 free to download, modify and redistribute this book. People outside of
21 the United States must check the copyright laws of their country
22 before downloading or redistributing.
23
24 [^1]: <http://copyright.cornell.edu/resources/publicdomain.cfm>
25
26 # Introduction
27
28 The Muddle language is described in "The Muddle Programming Language"
29 [^2], but in addition to the language itself, there is a rich and
30 varied collection of software written in the language which
31 facilitates the writing of programs and systems of programs in Muddle.
32 The information describing this programming environment has been
33 contained in various documents, some out of print or out of date, and
34 in supplemental disk files describing changes and additions. Some of
35 the packages of functions used to deal with Muddle code have never
36 been formally documented. This manual brings together some of that
37 scattered documentation.
38
39 [^2]: S. W. Galley and Greg Pfister.
40       *The Muddle Programming Language*.
41       MIT Laboratory for Computer Science, 1979.
42
43 The document's purpose is to flesh out the description of the language
44 contained in "The Muddle Programming Language", giving a fuller
45 description of the program writing and debugging aids available to
46 Muddle users, to describe the methods for producing code usable by
47 others, to describe the Muddle compiler and the many other techniques
48 for producing and speeding up Muddle object code.
49
50 The imagined reader of this document is someone who has read "The
51 Muddle Programming Language", and now proposes to write programs in
52 Muddle, possibly even very large programs. Muddle packages that they
53 would find useful in the process of doing so are documented here:
54 editors, debuggers, etc. Packages that they might wish to use within
55 their program are not included: data-management systems, command
56 interpreters, etc.
57
58 This document is highly self-referent, as many of the components of
59 the Muddle programming environment refer to reach other and adhere to
60 the same conventions. Additionally, this document assumes that the
61 read is familiar with the language itself (at least to some degree)
62 and with the ITS, TENEX, or TOPS-20 operating systems.
63
64 # Acknowledgments
65
66 The programs described in this document are the products of many years
67 of effort by many people. Most have been "touched" by several
68 programmers, added to and improved over the years.
69
70 Some of the people responsible for the programs mentioned in the
71 document are Chris Reeve (Muddle, the compiler, `GLUE`); Brian
72 Berkowitz (Muddle, the compiler, `TEMPLATE`, `SUBRFY`); Bruce Daniels
73 (Muddle, the compiler, `PACKAGE`, `PPRINT`, `DEBUGR`, `ASSEM`); Tim
74 Anderson (`PACKAGE`, the Library, `FINDATOM`, `DFL`, Combat, Mudinq);
75 Neal Ryan (`EDIT`, `PDUMP`, the IPC interface); Marc Blank (Mat,
76 Muxicom, `MONITR`, Combat, `EDIT`, `CURSOR`); Dave Lebling (`CRITIC`,
77 `EDIT`); Michael Broos (the Library); Roger Banks (`TRACE`); Greg
78 Pfister (`PPRINT`); Joel Berez (`EDIT`).
79
80 Most of the documentation in this manual is from published and
81 unpublished memos of the Programming Technology Division of the M.I.T.
82 Laboratory for Computer Science. As a general rule, updates and
83 revisions to this and other PTD documents concerning Muddle are
84 available online in the directory "`MUDMAN`" at MIT-DMS.
85
86 # Notation
87
88 Anything which is written in the Muddle language or which is typed on
89 a computer console appears here in in a typewriter font, as in
90 `PPRINT` while a metasyntactic variable -- something to be replaced in
91 actual use by something else -- appears as *channel*, in an italic
92 font. Where a meta-syntactic variable is being used to denote a
93 required argument to some function, it appears as before, but in bold,
94 as **channel**.
95
96 In the argument templates of Muddle functions, the individual
97 arguments are often given in the form *argument:type*, where
98 *argument* is a "descriptive" name for the argument, and *type* is its
99 Muddle type (or range of types). In such cases, the "type" *boolean*
100 indicates an argument that is only examined for truth or falsity, and
101 not for any of its other qualities. Such arguments in Muddle are often
102 declared `<OR ATOM FALSE>`.
103
104 Finally, file names are given as though for the ITS operating system:
105
106     device:sname;fnm1 fnm2
107
108 The analogous specification for TENEX or TOPS-20 would be
109
110     device:<sname>fnm1,fnm2
111
112 Note that in the TENEX/TOPS-20 version of Muddle, the *fnm2* (which
113 may include the *generation* number, *protection* and *account*
114 fields) is by default `MUD` as opposed to \> for the ITS version.
115
116 # 1\. Overview of the Muddle Programming Environment
117
118 The part of the Muddle programming environment described in this
119 document are primarily those dealing with the writing, debugging,
120 sharing, and maintenance of code and programs written in Muddle. Most
121 of the packages described herein are written in Muddle themselves:
122 some are assembly language programs useful to Muddle programmers.
123
124 The document is divided into chapters dealing with the major issues
125 facing the notice (or even the experienced) Muddle programmer:
126
127   - **The Package System** introduces the standard mechanism for
128     lexical blocking and therefore, sharing of Muddle code.
129     Understanding its use is fundamental to writing Muddle programs.
130
131   - **Program Writing And Debugging Aids** is the largest chapter. It
132     covers mechanisms for loading, dumping, editing and debugging
133     Muddle code, whether interpreted or compiled, in a development or
134     production system.
135
136   - **The Library System** discusses the usage of libraries of Muddle
137     programs.
138
139   - **The Compiler** includes the specifics of interaction with the
140     Muddle compiler, as well as an overview of the theory behind its
141     operation.
142
143   - **Making It Run Faster** covers the various methods for speeding
144     up "production" Muddle code by removing mediated calls and
145     compacting data structures.
146
147   - **The Assembler** documents the Muddle assembler and some methods
148     of debugging binary code.
149
150   - **Informational Aids** discusses a few programs, mostly written in
151     assembly language, rather than Muddle, which are useful to the
152     Muddle programmer.
153
154 # 2\. The Package System
155
156 The portion of the Muddle environment which provides a uniform
157 facility for lexical blocking is known as the Package System. In one
158 sense it is the most basic part of the environment, since it enables
159 many programmers to use each other's code without identifier
160 conflicts.
161
162 In addition, the Package System is interfaced to a library facility
163 (see section 4) by which Muddle code may be stored and later loaded as
164 needed.
165
166 The Package System is so basic to use of the Muddle environment that
167 (with a few exceptions) every subsystem or family of Muddle functions
168 described in this document is a "package".
169
170 ## 2.1. The Theory Of Lexical Blocking In Muddle
171
172 Lexical blocking is implemented in Muddle by means of `OBLIST`s and
173 `LIST`s of `OBLIST`s. Changes of lexical context are performed using
174 the `SUBR`s `BLOCK` and `ENDBLOCK`. The Package System provides a
175 high-level interface to these low-level constructs.
176
177 The primary goal of a lexical blocking scheme is the prevention of
178 identifier conflicts. Specifically, when your program references the
179 variable `X`, it should be your `X` and not that of some other
180 program. At the same time, it should not be necessary for a programmer
181 to search every program previously written to verify that an
182 identifier he wishes to use is not already "taken".
183
184 It should be clear that the simplest solution, a single `OBLIST`, will
185 not satisfy either of these goals. With only one `OBLIST` there would
186 necessarily be identifier conflicts, necessitating exhaustive
187 searching for unique identifiers.
188
189 Obviously, programmers could put their program's identifiers on an
190 `OBLIST` unique to that program. Unfortunately, such a solution
191 addresses only half the program. What happens when some other
192 programmer wishes to use some of this code? He could insert the unique
193 `OBLIST` for that program into the `OBLIST` path for his program; but
194 the moment that is done he gets all the identifiers for that program,
195 including local variable, internal data structures, and so on.
196
197 Consequently, we move to a situation where each program uses two
198 `OBLIST`s: one for the identifiers that are local to the program, and
199 one for the identifiers that are to be used by other programs. In the
200 Package System, these are known as the "internal" `OBLIST` and the
201 "entry" `OBLIST`.
202
203 Most of the identifiers in a program are local to it, and want to be
204 placed on the internal `OBLIST`. Therefore, in terms of an argument to
205 the `BLOCK` `SUBR`, when a program is being loaded into Muddle, the
206 `OBLIST` path wants to be:
207
208 ( *internal-oblist  
209 entry-oblist*  
210 `<ROOT>` )
211
212 With this `OBLIST` path, most `ATOM`s (identifiers) will be on the
213 internal `OBLIST` (as `READ` puts unknown identifiers on `<1
214 .OBLIST>`), but the `ATOM`s for the entries and the `ATOM`s for the
215 usual `SUBR`s will be available.
216
217 The only issue yet to be addressed is that of using an entry of a
218 different program in your program. This is accomplished by adding the
219 entry `OBLIST` of any such programs to the path after `ROOT`:
220
221 ( *internal-oblist  
222 entry-oblist*  
223 `<ROOT>`  
224 *other-program-entry-oblist  
225 yet-another-program-entry-oblist*  
226 .  
227 .  
228 . )
229
230 As only the entry `OBLIST`, and not the internal `OBLIST`, of the
231 program being used is added to the path, the chance of identifier
232 conflict is lessened.
233
234 All that remains is to introduce the functions by which these various
235 operations are performed.
236
237 ## 2.2. Package System Overview
238
239 The functions which make up the Package System are:
240
241   - `PACKAGE` - This indicates the start of a package of functions.
242
243   - `ENDPACKAGE` - This indicates the end of the package of functions.
244
245   - `ENTRY` - This indicates an `ATOM` which is to be made available
246     outside the definition of this package of functions. All other
247     `ATOM`s will not be directly available outside the package.
248
249   - `USE` - This indicates a reference by name to another package of
250     functions.
251
252   - `USE-DATUM` - This indicates a reference by name to a data set.
253
254   - `DROP` and `L-UNUSE` - These undo the effects of `USE` and
255     `USE-DATUM`.
256
257 These functions are themselves part of a package named `PKG`, which is
258 preloaded into Muddle.
259
260 ### 2.2.1. Sample Package
261
262 A sample Muddle `PACKAGE` is given with comments in order to
263 demonstrate the usage of these functions.
264
265     <PACKAGE "HOUR-STRING">
266     
267     ;"PACKAGE begins the package called HOUR-STRING."
268     
269     <ENTRY TIME-STRING>
270     
271     ;"The atom TIME-STRING is an entry to this package;
272      it may be referenced by other packages by
273      USEing HOUR-STRING."
274     
275     <USE "DATIME">
276     
277     ;"Indicate that the package DATIME is
278      used within the current package."
279     
280     <DEFINE TIME-STRING ()
281             <STRING <UNPARSE <HOURS>> " o'clock">>
282     
283     ;"Define this little function which returns a string
284      telling the last hour in a strange format."
285     
286     <DEFINE HOURS () <1 <RTIME>>>
287     
288     ;"Define an internal function which is available
289      only within the HOUR-STRING package, since its
290      name is not in any ENTRY statement.
291      Note that this function refers to RTIME,
292      which is an ENTRY in the DATIME package."
293     
294     <ENDPACKAGE>
295     
296     ;"The end of this little demonstration package."
297
298 ## 2.3. Package
299
300 This function delimits the beginning of a package of functions. It
301 takes one required argument, a `STRING`, which is the the name of the
302 package. This `STRING` uniquely identifies the package within a
303 library of packages (see section 4.)
304
305 In a `PACKAGE` those `ATOM`s which are specified as entries live in a
306 separate `OBLIST` of their own, called the entry `OBLIST`. The `ATOM`
307 naming this `OBLIST` is on the `PACKAGE` `OBLIST` and has the same
308 name as the package itself. Thus, an entry "X" of a `PACKAGE` "Y"
309 would have as its "full-trailer" name: `X!-Y!-PACKAGE!-`.
310
311 `PACKAGE` blocks (sets up) the current `OBLIST` path so that the
312 `ATOM`s which are internal to the `PACKAGE` fall into an `OBLIST`
313 which is not otherwise used. The `ATOM` naming this `OBLIST` is on the
314 entry `OBLIST` of the `PACKAGE`, and is by default given a name
315 created by putting the character I at the beginning of the `PACKAGE`
316 name. An internal `ATOM` "Z" in the `PACKAGE` "Y" previously mentioned
317 would have as its "full-trailer" name: `Z!-IY-Y!-PACKAGE!-`.
318
319 `PACKAGE` also keeps track of the fact that the particular `PACKAGE`
320 named has been defined in this Muddle process by putting its name on
321 the `PACKAGE` `OBLIST`.
322
323 `<PACKAGE` **name:string**  
324 *iname:string  
325 size:fix  
326 isize:fix*`>`
327
328 `PACKAGE` takes three optional arguments in addition to the required
329 one (the optional arguments are ignored if *name* is already a
330 `PACKAGE`):
331
332   - *iname* is the name of the internal `OBLIST` of the `PACKAGE`; by
333     default is is the name of the `PACKAGE` with the letter "I"
334     prefixed.
335
336   - *size* is the number of buckets in the entry `OBLIST`; by default
337     
338     19. 
339   - *isize* is the number of buckets in the internal `OBLIST`; by
340     default 23.
341
342 In addition to `PACKAGE`, there exists the obsolete function
343 `RPACKAGE`, documented here only because some programs still use it.
344 The difference between them is that the entry `OBLIST` for an
345 `RPACKAGE` is the `ROOT` `OBLIST`. The implication of inserting an
346 entry into the `ROOT` is that this requires the name of the entry be
347 unique over all `PACKAGE`s, because the entry is, in effect, being
348 promoted to the status of a `SUBR`. It is (in rare cases) useful to do
349 this, but the correct way is with the function `RENTRY` (see section
350 2.3.1.)
351
352 ### 2.3.1. Entry
353
354 The `ENTRY` function applied to one or more `ATOM`s declares that
355 these `ATOM`s are to be put into the `OBLIST` reserved for entries in
356 this particular `PACKAGE`. Only `ATOM`s declared this way will be
357 accessible (in the normal course of events) to functions outside this
358 `PACKAGE`.
359
360 It is possible to place some entries of a `PACKAGE` on the `ROOT`
361 `OBLIST` using the function `RENTRY`. It is recommended that instead
362 of using `RPACKAGE` in those rare cases where entries must go on the
363 `ROOT`, `RENTRY` be used instead.
364
365 All `ENTRY` statements should appear immediately after the `PACKAGE`
366 or `RPACKAGE` statement. Note: never put a `USE` statement before the
367 `ENTRY` statements; if you do, you may get the `ERROR` message
368 `ALREADY-USED-ELSEWHERE`, meaning that the name of an entry is
369 conflicting with an `ENTRY` in one of the packages you `USE`d. `ENTRY`
370 will also give an `ERROR` if it is used outside the body of a
371 `PACKAGE`.
372
373 ### 2.3.2. USE
374
375 This function takes as arguments one or more `STRING`s which are the
376 names (as given to `PACKAGE`) of other `PACKAGE`s. `EXTERNAL` is a
377 synonym of `USE`. `USE` causes the entry `OBLIST`s of the `PACKAGE`s
378 named to be spliced into the current `OBLIST` path. Thus, references
379 to entries of those `PACKAGE`s may be made after the `USE`, until the
380 next `ENDPACKAGE` (or the next `DROP` or `L-UNUSE` if `USE` is being
381 invoked outside a `PACKAGE` to load a file.)
382
383 `USE` is consequently the mechanism for sharing code. If the `PACKAGE`
384 being used is already loaded, its entries are made available; if not,
385 the `PACKAGE` is loaded first (see section 4.1 for details on how this
386 is accomplished.)
387
388 ### 2.3.3. USE-DATUM
389
390 `USE-DATUM` requires one `STRING` argument, the name of a data set. If
391 the data set is not loaded, `USE-DATUM` loads it and creates an `ATOM`
392 of the same name, on the `USE-DATUM` `OBLIST`, whose `GVAL` is the
393 data set. `USE-DATUM` always `EVAL`s to the data set named, regardless
394 of whether it had to be loaded or not.
395
396 ### 2.3.4. DROP and L-UNUSE
397
398 These function take the same arguments as `USE` and `USE-DATUM` and
399 undo their effects.
400
401 `DROP` simply splices the named packages out of the current `OBLIST`
402 path. A `USE` of a `DROP`ped `PACKAGE` will not reload the `PACKAGE`
403 but simply splice it back into the `OBLIST` path.
404
405 `L-UNUSE` splices the `PACKAGE` out and removes its name from the
406 `PACKAGE` `OBLIST`, which will cause the entire `PACKAGE` to be
407 reloaded if it is `USE`d again. `L-UNUSED` of a data set will remove
408 its `ATOM` from the `USE-DATUM` `OBLIST`.
409
410 ### 2.3.5. ENDPACKAGE
411
412 The `ENDPACKAGE` function of no arguments terminates the definition of
413 the current `PACKAGE` and undoes the lexical blocking done by the
414 `PACKAGE` function. The `ENDPACKAGE` statement should be the last one
415 in the file.
416
417 ### 2.3.6. PACKAGE Restrictions
418
419 There are some restrictions on what the user may do inside a
420 `PACKAGE`. These are enforced by the Library System when the user
421 attempts to submit a `PACKAGE` to a library.
422
423 A `PACKAGE` should not `FLOAD` or `LOAD` any file to obtain parts of
424 itself. All such environment setup should be done with `USE` and
425 `USE-DATUM`.
426
427 A `PACKAGE` may not reference any `ATOM` whose `OBLIST` path goes
428 through the `INITIAL` `OBLIST`. All of the non-entry `ATOM`s in a
429 package should fall naturally into it's internal `OBLIST`.
430
431 As mentioned before, the `RENTRY` of a package have the same `OBLIST`
432 status as `SUBR`s, i.e., they must be unique among both all `SUBR`s
433 and all `PACKAGE` entries.
434
435 ### 2.3.7. ENTRY Name Conflicts
436
437 It is possible to have two or more `PACKAGE`s (not `RPACKAGE`s) which
438 have entries (not `RENTRY`s) with the same `PNAME`. If the user needs
439 both `PACKAGE`s at the same time, he may `USE` them both and refer to
440 the ambiguous entries by their "full trailer" names. All of the
441 non-ambiguous entries in `PACKAGE`s may still be referenced by `PNAME`
442 only.
443
444 # 3\. Program Writing and Debugging Aids
445
446 This chapter concentrates on editing and debugging aids for Muddle
447 programming. The basis for editing and debugging in Muddle is twofold:
448 First, Muddle is an interpreter, which permits interactive testing and
449 debugging of software. Second, Muddle programs (even compiled Muddle
450 programs) are structures and therefore may be manipulated by other
451 Muddle programs.
452
453 Packages useful in editing and debugging range from `EDIT` and
454 `PPRINT`, which are preloaded, and which form the core of most editing
455 or debugging systems, to more sophisticated aids such as `DEBUGR` and
456 `TRACE`, which are more powerful, and useful for more complicated
457 debugging.
458
459 It should be noted that, in addition to the editors discussed below,
460 RMODE [^3] and EMACS [^4], TECO based text editors, understand much of
461 the syntax and many of the conventions of Muddle programs.
462
463 [^3]: P. David Lebling, R. V. Baron and Bruce K. Daniels.
464      *RMODE: A Real-time Edit Facility*.
465      Technical Report SYS.04.07-1, MIT LCS Programming Technology
466 Division, October 1977.
467
468 [^4]: Richard M. Stallman.
469      *EMACS*.
470      Technical Report 519, MIT AI Laboratory, August, 1979.
471
472 ## 3.1. Pretty-Printing
473
474 The purpose of pretty printing is to clarify the structure of Muddle
475 objects by printing them in a more human-readable format than that
476 provided by the `SUBR`s `PRINT`, `PRIN1`, etc. Objects are
477 pretty-printed through the judicious insertion of spaces, tabs, and
478 new-lines between tokens. Pretty-printed objects are readable by the
479 Muddle Reader. Pretty printing is an aid to understanding and
480 debugging Muddle `FUNCTION`s or other objects. You will probably find
481 pretty printing to be extremely helpful, especially if you are working
482 without a listing or with an old listing. In fact, pretty-printing is
483 one way to make a new pretty listing after editing. `PPRINT` is
484 pre-loaded in most initial Muddles. The name of the package containing
485 `PPRINT` is "`PP`".
486
487 `<PPRINT` **any** *channel*`>`
488
489 pretty-prints *any* on *channel*. The second argument is option, by
490 default `.OUTCHAN`. If *any* is an `ATOM`, `PPRINT` will enclose it in
491 an application of `DEFINE`, `DEFMAC`, `SETG`, or `SET`, as seems
492 appropriate. `COMMENT`s found inside *any* are right-justified.
493 `PPRINT` cannot output an `RSUBR` without `FIXUP`s (that is, one that
494 was `READ` in while `KEEP-FIXUPS` (see section 3.4) had no `LVAL` or
495 had a `FALSE` `LVAL`); it will give the `ERROR` message
496 `CAN-NOT-BE-DUMPED`. `PPRINT` returns `.NULL` which is an `ATOM` whose
497 `PNAME` is a single rubout, invisible on most consoles.
498
499 `<PPRINF` **in:string-or-atom-or-list** *outfile:string  
500 width:fix eval?:boolean*`>`
501
502 pretty-prints all the contents of *in* into *outfile*.
503
504 If *in* is an `ATOM` or a `LIST` of `ATOM`s, its `VALUE`(s) are the
505 objects to be `PPRINT`ed. In this case, *outfile* is by default a file
506 whose first name is produced by taking the `PNAME` of *in* (or *in*'s
507 first element, if *in* is a `LIST`).
508
509 If *in* is a `STRING`, it specifies a file containing objects to
510 `PPRINT`. In this case, *outfile* is by default "`TPL:`".
511
512 *width* is the maximum width of output lines (although output lines
513 are prevented from being extremely long); it is optional, and by
514 default `<13 ,OUTCHAN>`.
515
516 *eval?* tells `PPRINF` whether or not to `EVAL` everything in the
517 file; it is optional, by default a `FALSE` (don't `EVAL`). *eval?* is
518 meaningless if *in* is not a `STRING`.
519
520 `PPRINF` returns either "`DONE`" or a `FALSE` if it couldn't open
521 *infile* or \*outfile(. `PPRINF` inserts page boundaries in *outfile*,
522 between objects, every 60 lines or fewer; you may want to move these
523 afterward to more logical places. `PPRINF` binds `KEEP-FIXUPS` and
524 `REDEFINE` to `T`, and `QUICKPRINT` (see below) to a `FALSE`.
525
526 ### 3.1.1. PPRINT Control Switches
527
528 `PPRINT`'s output is affected by the local values of several `ATOM`s.
529 Each value is examined only for truth.
530
531     .QUICKPRINT
532
533 If this `ATOM`'s `LVAL` is `FALSE`, you are in slow mode; otherwise
534 (include the case of no `LVAL`), you are in fast mode. The behavioral
535 difference is this: in fast mode, there may be `COMMENT`s in the
536 pretty-printed object(s) which `PPRINT` misses. Also, fast mode is
537 indeed faster than slow mode. Fast mode is the default, that is,
538 `QUICKPRINT` is initially true. The modes are really distinguished by
539 the depth of recursion to which PPRINT resorts. In slow mode, it
540 recurses all the way down to every monad in the thing pretty-printed;
541 in fast mode, it goes down only far enough to find something that will
542 fit on a line.
543
544     .LOOKAHEAD
545
546 `PPRINT` uses full recursive lookahead to avoid packing things against
547 the right margin and, as a result, not being able to fit things within
548 the right margin. The lookahead results in very good formatting of
549 deeply-nested `MAPF`ed and `FUNCTION`s; all but the most bizarre cases
550 should be very legible. However, it can result in noticeable "pauses"
551 in the printing operation and, in some cases, a net speed slightly
552 less than with limited lookahead. Since this can be a disadvantage
553 when using `PPRINT` interactively on a heavily-loaded system, the
554 lookahead can be disabled: if the `LVAL` of `LOOKAHEAD` is a `FALSE`,
555 no lookahead will be performed; otherwise it happens. `LOOKAHEAD` is
556 initially true, that is, lookahead happens by default.
557
558     .VERTICAL
559
560 If `LOOKAHEAD` is a `FALSE`, the formatting can cause too many objects
561 to be squeezed against the right margin. So that particular cases can
562 be made legible, the format when lookahead is not in use can be
563 manually set: if the `LVAL` of `VERTICAL` is non-`FALSE`, `PPRINT`
564 will indent very little whenever indenting is called for. (`VERTICAL`
565 being true means a "more vertical" format.) `VERTICAL` is initially
566 `FALSE`. The value of `VERTICAL` is ignored when `LOOKAHEAD` is true;
567 the lookahead effective chooses different values for `VERTICAL` for
568 different parts of the object pretty-printed.
569
570 ### 3.1.2. Lower-level Pretty Printing
571
572 It is sometimes desirable to use some of the functions that `PPRINT`
573 uses but in a different way. For example, a specialized pretty-printer
574 for Program Abstracts would want to insert indented field names into
575 the output and pretty-print field values with the same indentation.
576 The names of lower-level pretty-print functions are included in the
577 `ROOT` `OBLIST` for such purposes.
578
579 `<EPRINT` **any** *left-margin:fix*`>`
580
581 pretty-prints *any* on `.OUTCHAN` to the right of *left-margin*. The
582 second argument is optional, by default `<VALUE LEFT-MARGIN>` (see
583 below.)
584
585 `<EPRINT` **any** *left-margin:fix*`>`
586
587 `EPRIN1` is to `EPRINT` as `PRIN1` is to `PRINT`.
588
589     .LEFT-MARGIN
590
591 This is the `ATOM` that `EPRINT` binds to its second argument. You can
592 `SET` it outside calls to `EPRINT` in order to make a permanent left
593 margin. Its initial `LVAL` IS 0.
594
595 `<INDENT-TO` **column:fix** *channel*`>`
596
597 outputs tabs and/or spaces to advance the output column (`<14
598 channel>`) to *column*, if it is not already past.
599
600 `<COLPP` **any**  
601 *channel  
602 left-margin:fix  
603 right-margin:fix*`>`
604
605 pretty-prints *any* on *channel* (by default `.OUTCHAN`) between the
606 margin *left-margin* (by default `<14 channel>`, the current column)
607 and *right-margin* \*by default `<13 channel>`, the rightmost column.)
608 All arguments but the first are optional. `COLPP` returns `,NULL`. For
609 example, `<COLPP any .OUTCHAN 10 70>` would leave a 10-character
610 margin at left and right on an 80-column `OUTCHAN`. Also,
611
612     <PRINT () PRINT AAAAAAAAAAAAAAA> <COLPP ,FOO>>
613
614 would result in output like
615
616     AAAAAAAAAAAAAAA #FUNCTION ((X GGGGGGGGGGGGGGGGGGGGGG)
617                               <+ X 1>)
618
619 `EPRINT`, `EPRIN1`, and `COLPP` are affected by the truth of
620 `.QUICKPRINT`, `.LOOKAHEAD`, AND `.VERTICAL`.
621
622 ### 3.1.3. Ampersand Printing
623
624 "Ampersand printing" consists of printing any object on a single line
625 by using the character `&` (ampersand) to mean "There's more stuff
626 here." (This technique is borrowed by the InterLisp editor.)
627
628 There are two ways in which `&` is used by this printer as an
629 abbreviation:
630
631 1.  An `&` appearing between some variety of brackets indicates that
632     there is a big object of the indicated `TYPE` there.
633 2.  The characters `..&` or `&..` on the left or right of a structure
634     mean that there are more objects to the left or right which have
635     not been printed.
636
637 Example:
638
639     #FUNCTION ((A B C D) <&>)
640
641 This is a `FUNCTION` with four arguments in its argument `LIST`, and
642 the `FUNCTION` body contains one `FORM` which was too big to print in
643 the remainder of the line.
644
645     <PROG () <KRK <+ /A 5>> <PRINC .Q> <SET BAR <ORG>> <&> &..>
646
647 This is a large `FORM`, namely a `PROG`. In addition to the elements
648 printed, there are more elements to the right, and there is one `FORM`
649 which was too big to print.
650
651 Ampersand printing is effected by two pure `RSUBR`s: `&`, analogous to
652 `PRINT`, and `&1`, analogous to `PRIN1`. A related `RSUBR`, `&LIS`,
653 can be applied to no arguments to put you into an endless
654 `READ-EVAL-&` loop, instead of the normal `READ-EVAL-PRINT` loop.
655
656 ### 3.1.4. Examining the stack
657
658 `<FRM` **fix**`>`
659
660 returns the *fix*th `FRAME` down from the top application of `ERROR`
661 or `LISTEN`.
662
663 `<FRAMES` *how-many:fix start:fix*`>`
664
665 pretty-prints *how-many* `FRAME`s (by printing the `FRAME` number
666 (suitable as an argument to `FRM`), `FUNCT`, and `ARGS` of the
667 `FRAME`), starting with `<FRM` *start*`>`. Both arguments are
668 optional; *start* defaults to 0, and *how-many* defaults to a large
669 integer. A `FRAME` whose `FUNCT` is an `ATOM` whose `VALUE` is an
670 `FSUBR` is not printed, if the same information is found in the next
671 lower `FRAME`.
672
673 `<FR&` *how-many:fix start:fix*`>`
674
675 is like `FRAMES but uses ampersand printing instead of pretty
676 printing. It is handy for summarizing`FUNCT`s and`ARGS`that are large
677 or unprintable (like`RSUBR\`s with no fixups).
678
679 `<FRATM` *how-many:fix start:fix*`>`
680
681 is like `FRAMES` but gives an abbreviated view of the stack. It prints
682 `FUNCT`s only, and only for `FRAME`s connected with named `FUNCTION`s,
683 `RSUBR`s, and `RSUBR-ENTRY`s. It is handy when a `FRAME` contains a
684 non-`LEGAL?` object.
685
686 `<FRLVAL` **atom**  
687 *how-many:fix  
688 start:fix*`>`
689
690 prints out the stacked bindings of *atom*, going through *how-many*
691 `FRAME`s, starting with `<FRM` *start*`>`. The two numeric arguments
692 are optional; *how-many* defaults to a large integer, and *start*
693 defaults to 0. The format of the printing is two columns: the first
694 column is the number of the `FRAME` in which *atom* has a binding; the
695 second column is the value bound, or a message proclaiming the lack of
696 a value.
697
698 `<FR&VAL **atom**\ *how-many:fix\ start:fix*`\>\`
699
700 is precisely the same as FRLVAL, except that the values are ampersand
701 printed instead of `PRINT`ed.
702
703 Finally, the "`FRMSP`" `PACKAGE` contains analogues of many of the
704 preceding functions, but each takes as its first argument a `PROCESS`,
705 by default `<ME>`. These are all named by adding a 'P' to the end of
706 the usual name. For example,
707
708     <FR&P <MAIN>>
709
710 Does does a `<FR&>` in the `PROCESS` `MAIN`.
711
712 There is one additional function of interest in "FRMSP".
713
714 `<FRTYPE` *how-many:fix start:fix*`>`
715
716 is like `FRAMES`, but gives only the `TYPE`s of the arguments to each.
717 This is useful in those situations when the stack shows illegal
718 `FRAME`s or other unprintable objects.
719
720 ## 3.2. The Muddle Editor
721
722 `EDIT` allows a Muddle user to make incremental changes in Muddle
723 structured objects, without leaving Muddle and with the ability to
724 save the results in a file, and to set or clear conditional
725 breakpoints of various sorts in objects that will be evaluated, such
726 as `FUNCTION`s.
727
728 `EDIT` is an editor/debugger written in, written for, and running
729 under Muddle. It comprises the package "`EDIT`" and several smaller
730 packages which wi11 be mentioned later in this section. `EDIT` is
731 preloaded in most initial Muddles.
732
733 To start editing, apply `EDIT` to no arguments or to the name of the
734 object you wish to edit: `<EDIT>` causes entry into `EDIT` and opens
735 the last object edited; `<EDIT` *object*`>` causes entry into `EDIT`
736 and opens *object* for editing. Permissible *object*s include:
737
738   - `ATOM`s. The `GVAL` (preferably) or the `LVAL` of the `ATOM` is
739     opened. If it has no value, `EDIT` returns a `FALSE`.
740
741   - A `PRIMTYPE` `LIST`. The `PRIMTYPE` `LIST` is opened.
742
743   - A `FIX`. The stack frame with that number is opened (i.e., `<ARGS
744     <FRM` *fix*`>>`).
745
746 Part of `EDIT`'s efficiency comes from forbidding it to delve into
747 objects that are not of `PRIMTYPE` `LIST`, that is, not `LIST`s,
748 `FORM`s, `FUNCTION`s, etc. Attempts to edit objects of other
749 `PRIMTYPE`s will result in error messages. These objects can, however.
750 be treated as units when inserting. searching, etc.; or they can be
751 changed into `LIST`s, edited, and then changed back to their original
752 types.
753
754 ### 3.2.1. The Edit 'LISTEN Loop'
755
756 #### 3.2.1.1. The Reader
757
758 When in `EDIT`, you are typing at a special, non-standard, input
759 function: The `EDIT` Reader.
760
761 The Reader allows you to type `EDIT` commands and have them executed,
762 and also to evaluate Muddle expressions normally. Its characteristics
763 are as follows:
764
765   - As in the normal Muddle Reader, nothing is done until you type
766     `ESC`. `DEL`, `Ctrl-L`, `Ctrl-D`, `Ctrl-G`, and `Ctrl-S` also work
767     normally.
768
769   - All `EDIT` commands are terminated when an `ESC` is encountered in
770     the input stream. (In addition. most commands will terminate
771     whenever the maximum number of arguments required has been input
772     or whenever an argument of the wrong type is encountered. In the
773     former case the next object is taken as a new command; in the
774     latter case the object of the wrong type is taken as a new
775     command. `EDIT` commands may be typed in either upper or
776     lowercase.
777
778   - If you type something that `EDIT` does not recognize as a command,
779     normal Muddle evaluation and printing are performed on that
780     something. This evaluation will have no effect on your position in
781     the object you are editing.
782
783   - While editing a function which is part of a `PACKAGE` (determined
784     from an examination of the `OBLIST` containing the `ATOM` whose
785     value is the function), `EDIT` causes the OBLIST path to be set up
786     to what it was in the environment of that `PACKAGE`. This has the
787     advantage of reducing the number of trailers printed, and causes
788     newly entered `ATOM`s to fall on the correct `OBLIST` (the
789     internal `OBLIST` of the `PACKAGE`). It has the slight
790     disadvantage that it disables the dynamic loader (which depends on
791     unbound variables falling on the `INITIAL` `OBLIST`). If the
792     `GVAL` of `E-PKG` is a `FALSE`, this feature is disabled, and the
793     normal `OBLIST` path is in effect during editing.
794
795 Examples:
796
797     R 5$
798
799 Causes execution of `EDIT` command R with argument 5.
800
801     <R 5>$
802
803 Causes application of the function R to 5.
804
805 #### 3.2.1.2. The Ampersand Printer
806
807 Your current position is displayed by "ampersand printing" (see
808 section 3.1.3). This consists of printing any object on a single line
809 by using the character `&` (ampersand) to mean "There's more stuff
810 here."
811
812 The ampersand printer used in `EDIT` is much like the standard one,
813 with the addition that your current position (see below) is displayed
814 by the glyph of a solid square: &block;.
815
816 When you initially enter `EDIT`, you are in a mode called
817 "non-verbose", in which ampersand printing is not automatically done
818 following execution of `EDIT` commands. The `V` command is used to
819 toggle you in and out of verbose mode (see below).
820
821 Examples:
822
823 `<FUNCTION (` &block; `(A B C D) <&>>`
824
825 Indicates that your position is just to the left of a `FUNCTION`'s
826 argument list. and the `FUNCTION` body contains one `FORM` which was
827 too big to print.
828
829 `<..& <KRK <+A .A 5>>` &block; `<SET BAR <ORG>> <&> *..>`
830
831 Indicates that you are in the middle of a large `FORM` (e.g., a
832 `REPEAT` or a `PROG`), positioned just to the left of the `<SET BAR
833 <ORG>>`. In addition to the objects printed, there are more objects to
834 both the left and the right, and there is one `FORM` which was too
835 large to fit on the line.
836
837 ### 3.2.2. Edit Commands
838
839 #### 3.2.2.1. General
840
841 A sequence of `EDIT` commands is executed as soon as you type `ESC`.
842 If one command fails, subsequent commands up to the `ESC` are ignored,
843 and EDIT types out an appropriate error message. A failing
844 `EDIT`command generally has no effect whatsoever; but see individual
845 descriptions.
846
847 Note that *all* arguments to `EDIT` functions must be legal Muddle
848 objects. In particular, you can't search for `<SET`, since the `<>`'s
849 aren't balanced. Nor can you insert it. (But you can, for instance,
850 search for and insert `<SET THING 1>`.)
851
852 If a command expects an argument and doesn't get one, an error message
853 will be printed.
854
855 Many `EDIT` commands take `FIX`es as arguments. Those that do
856 interpret the `ATOM` \* as an argument to mean "as many as possible".
857
858 Whenever you are in `EDIT`, you have a well-defined "position". A
859 position is a "place" *inside* a Muddle structure: this "place" is
860 either *between* two elements elements of the structure, or between an
861 element and either end of the structure, or *inside* an empty
862 structure. All editing, movement, and printing commands operate
863 relative to your current position. The term "cursor" is used in the
864 following descriptions to refer to an embodiment of a position.
865
866 The format listed in each of the following command descriptions is:
867
868 Command as Typed  
869 English Name  
870 Description
871
872 #### 3.2.2.2. General Commands
873
874 `?`  
875 `duh?`  
876 Causes a short summary of all EDIT commands to be typed out. The same
877 summary appears later in this chapter.
878
879 `??`  
880 `huh?`  
881 Similar to the above, but the summary is even shorter, and should fit
882 entirely on the screen of an Imlac terminal.
883
884 `Q`  
885 `Quit`  
886 Leave `EDIT` and return to Muddle. (Causes `EDIT` to return the `ATOM`
887 `T`.)
888
889 `QR` *fix*  
890 `Quit and Retry`  
891 Quit from `EDIT` and then retry the frame specified, or by default,
892 the one originally given to an open command or, if none was given, the
893 frame beneath the last `ERROR` or `LISTEN` frame.
894
895 `Ctrl-F`  
896 `Control-F`  
897 This is not really an `EDIT` command; rather, it is a character,
898 obtained from the input stream at interrupt level, which is used to
899 return you to the `EDIT` Reader from some higher level of application,
900 e.g., an `ERROR`'s `LISTEN`. It is the `EDIT` equivalent of `ERRET`
901 with no arguments.
902
903 `Ctrl-F` (or `Ctrl-S`) typed during execution of an `EDIT` command is
904 similar to normal Muddle `Ctrl-S` but returns to the `EDIT` Reader
905 instead of the Muddle `LISTEN` loop.
906
907 `O` **object**  
908 `Open`  
909 Equivalent to `Q` followed by `<EDIT` *object*`>`. Positions the
910 cursor just to the left of the first element of the entire object
911 specified.
912
913 `OT`  
914 `Open This`  
915 If the object to the right of the cursor is an `ATOM`, or a `FORM`
916 whose first element `ATOM`, and the `ATOM`'s value is openable, then
917 it is opened. This command is useful when tracing a calling sequence
918 through several functions.
919
920 #### 3.2.2.3. Movement Commands
921
922 `UT`  
923 `Up to the Top`  
924 Places the cursor at the position it had following an `O`.
925
926 `R` *fix*  
927 `Right`  
928 Moves the cursor *fix* objects to the right, by default one. If *fix*
929 is too large, i.e., there are not that many positions to the right of
930 the current position, `EDIT` prints an error comment and the cursor
931 stays where it is.
932
933 `B`  
934 `Back`  
935 Moves the cursor as far to the right as possible.
936
937 `L` *fix*  
938 `Left`  
939 Moves the cursor \*fix( positions to the left, by default one. If
940 *fix* is too large, EDIT prints an error message.
941
942 `F`  
943 `Front`  
944 Moves the cursor as far to the left as possible.
945
946 `DL`  
947 `Down Left`  
948 Positions the cursor just to the right of the rightmost element within
949 the object to the left of the cursor, if that object is of `PRIMETYPE`
950 `LIST`. Visually, the cursor moves left over one "close bracket".
951
952 `DR`  
953 `Down Right`  
954 Positions the cursor just to the left of the leftmost element within
955 the object to the right of the cursor, if that object is of `PRIMTYPE`
956 `LIST`. Visually. the cursor moves right over one "open bracket". If
957 the cursor is to the left of an element that is not of `PRIMETYPE`
958 `LIST`, `EDIT` prints an error message.
959
960 `D`  
961 `Down`  
962 Equivalent to `DR`.
963
964 `UR` *fix*  
965 `Up Right`  
966 Positions the cursor just to the right of the object the cursor is
967 currently within. Does so `fix` times, by default once.
968
969 `UL` *fix*  
970 `Up Left`  
971 Positions the cursor just to the left of the object the cursor is
972 currently within. Does so *fix* times, by default once.
973
974 `U` *fix*  
975 `Up`  
976 Identical to `UL`.
977
978 `S` *object*  
979 Search  
980 Does a depth-first, left-first tree-walk. (i.e., left-to-right)
981 starting with the object to the right of the cursor. until the cursor
982 is just to the right of an object structurally equal (i.e., =?) to its
983 argument. An occurrence of the object will not be found if it is
984 inside anything not of `PRIMETYPE` `LIST`. On failure. the cursor does
985 not move. If the argument is omitted, the last object searched for is
986 used.
987
988 `SR` *object*  
989 `Search Right`  
990 Same as `S`.
991
992 `SL` *object*  
993 `Search Left`  
994 Same as `S`, but the tree-walk is depth-first, right-first (i.e.,
995 right-to-left) and you end up to the left of the object for which you
996 were searching.
997
998 #### 3.2.2.4. Printing Commands
999
1000 `The Empty Command`  
1001 Causes the normal "ampersand print" to be done. This is principally
1002 useful when you are in "silent" mode; see the `V` command.
1003
1004 By the way, an "empty" command is typed by typing `ESC` without having
1005 typed any visible characters before it.
1006
1007 `P`  
1008 `Print`  
1009 `PPRINT`s (not "ampersand prints") the object to the right of the
1010 cursor.
1011
1012 `PU`  
1013 `Print Up`  
1014 `PPRINT`s the object the cursor is in. This is similar to doing a `U`
1015 and then a `P`, although the cursor is not moved.
1016
1017 `PT`  
1018 `Print Top`  
1019 `PPRINT`s the whole object you have open.
1020
1021 `V`  
1022 `Verbosity`  
1023 Toggles the verbosity mode between "verbose" (most commands cause
1024 ampersand printing) and "silent" (printing of any sort is done only
1025 when some explicit print command is used, or when an error occurs.)
1026 The current state of verbosity is the `G-VAL` of `E-VERBOSE`.
1027
1028 In silent mode, absolutely *nothing* is printed after each command,
1029 not even new-lines or prompts. However, normal Muddle evaluation still
1030 causes normal Muddle printing.
1031
1032 #### 3.2.2.5 Editing Commands
1033
1034 `I` **any** ...  
1035 `Insert`  
1036 Inserts all its arguments immediately to the right of the cursor. None
1037 of its arguments are evaluated; you can insert unevaluated `FORM`s
1038 without using `QUOTE`. The cursor ends up to the right of the last
1039 object inserted.
1040
1041 `G` **any** ...  
1042 `Get`  
1043 Same as `I`, but its arguments are evaluated. This is useful in
1044 conjunction with the `X` command (see below.)
1045
1046 `I:` *type:atom fix*  
1047 `Insert Type`  
1048 Grabs *fix* objects to the right of the cursor, inserts them into a
1049 newly created object of `TYPE` *type*, deletes them from the original
1050 structure, and inserts the newly created object in their place. In
1051 other words, it "inserts" the appropriate open and close brackets for
1052 *type* at the cursor and *fix* objects to the right.
1053
1054 By default *fix* is one, *type* is `LIST`. An error message is printed
1055 if *fix* is larger than the number of objects to the right of the
1056 cursor.
1057
1058 There is no way to directly insert or delete single parentheses,
1059 brackets, etc. using `EDIT`. Insert, use `K:` (see below) to remove
1060 pairs of brackets, and `I:` to insert them.
1061
1062 `I*` *indicator:atom* **new-structure**  
1063 `Imbed`  
1064 Imbed looks for all occurrences of *indicator* in *new-structure* and
1065 replaces these occurrences with objects taken and deleted from the
1066 right of the cursor. In then inserts the result.
1067
1068 If only *new-structure* is given, the *indicator* is the `ATOM` \*. If
1069 there aren't enough objects to the right of the cursor to replace each
1070 `indicator`, remaining indicators are left untouched and a warning
1071 message is printed.
1072
1073 `I*` is generally used to insert one or more structures into another
1074 complex structure in one operation, instead of several. For example:
1075
1076 `<SET X` &block; `<12 .Y>>`  
1077 `I* <COND (<NOT <LENGTH? .Y 11>> *)>$`  
1078 `<SET X <COND (<NOT <LENGTH? .Y 11>> <12 .Y>)>` &block; `>`
1079
1080 Places a protective conditional around an `NTH` to prevent an
1081 out-of-bounds error.
1082
1083 `IG` **any** ...  
1084 `Insert Into Group`  
1085 Insert into a group. `IG` is similar to `I`, but assumes that the
1086 object you are in is a group (as produced by `GROUP-LOAD`). Arguments
1087 to `IG` which are not `ATOM`s are inserted as `I`, Objects which are
1088 `ATOM`s and which have a value insert a `FORM` which `DEFINE`s,
1089 `SETG`s, or `SET`s the `ATOM` as appropriate. Thus, to add a new
1090 function `F` to a group \`G1 one could type:
1091
1092     O G$IG F$Q$
1093
1094 `K` *fix*  
1095 `Kill`  
1096 Deletes `fix` objects to the right of the cursor. Defaults to one.
1097 Negative `fix` causes deletion to the left of the cursor.
1098
1099 `C` **any**  
1100 `Change`  
1101 Changes the one object to the right of the cursor so its single
1102 argument. Does not move the cursor. Does not evaluate is argument. `C`
1103 is more efficient than `K` plus `I`.
1104
1105 `C:` **type:atom**  
1106 `Change Type`  
1107 Changes the type of object to the right of the cursor to *type*.
1108 Attempts to do something reasonable for every type change. If you tell
1109 it to change a `STRING` to a`LIST`, you get a `LIST` of `CHARACTER`s.
1110 If you attempt to change a structure whose elements are other than
1111 `CHARACTER`s and `STRING`s to a `STRING`, you will get a Muddle error.
1112
1113 `K:`  
1114 `Kill Type`  
1115 Deletes the brackets around the object to the right of the cursor i.e.
1116 kills the object and inserts its elements into the structure of which
1117 it was a part.
1118
1119 `SU` **new** **old**  
1120 `Substitute`  
1121 The Substitute command takes two arguments. All occurrences of *old*
1122 from the current location to the end of the open object (actually a
1123 search-right is done) are replaced by *new*. Once the search for *old*
1124 fails, the command terminates, and the number of substitutions
1125 performed is printed. The cursor is left after the last object
1126 replaced.
1127
1128 `X` **atom**  
1129 `Transfer`  
1130 `SET`s the *atom* to the object to the right of the cursor. `X` can be
1131 used with `K` and `G` to move things around within the object being
1132 edited.
1133
1134 `SW`  
1135 `Swap`  
1136 Swaps the two objects to right of the cursor, leaving the cursor
1137 pointing at the same object. The effect is to move the cursor and the
1138 object it points at one object to the right. Repeated `SW`s move
1139 cursor and object further and further to the right.
1140
1141 #### 3.2.2.6. Macro Facility
1142
1143 `M` **macro**  
1144 `Macro`  
1145 Takes either a `STRING` or something which `EVAL`s to a `STRING` and
1146 performs all of the commands in the `STRING`. For complete assurance
1147 that your commands will be done properly, put an ESC between commands.
1148
1149 `IT` **fix** *macro*  
1150 Iterate  
1151 This command (also called DO) takes a *fix* and macro as if an
1152 argument to `M`. This command will loop through the *macro* *fix*
1153 times or until an error is generated. When the iteration ends, the
1154 user is told how many complete passes have been made of the `macro`.
1155
1156 In both of the above commands, if an `EDIT` error is generated, the
1157 *macro* will be terminated, and the *macro* itself will be printed,
1158 with an arrow pointing to the offending command. The cursor wilt
1159 remain at the place where the last legal command left it.
1160
1161 The SU command is, internally:  
1162 `DO * "S` *old*`$L$C` *new*`$"`
1163
1164 #### 3.2.2.7. Cursors
1165
1166 Cursors are locations in objects being `EDIT`ed. In addition to the
1167 main cursor, which is where editing occurs, other locations (also
1168 called cursors) may be remembered. The main cursor may be moved to
1169 another cursor in a single operation, potentially saving many motion
1170 commands. In large `FUNCTION`s cursors may also reduce confusion by
1171 distinguishing among several similar areas of code.
1172
1173 `UC`  
1174 `Use Cursors`  
1175 The `PACKAGE` for dealing with cursors is not normally loaded in an
1176 initial Muddle, so the UC command loads it and makes the cursor
1177 commands available. The `PACKAGE` loaded is "`CURSOR`".
1178
1179 `CU` *atom*  
1180 `Cursor`  
1181 `CU` takes an `ATOM` argument and `SET`s the `ATOM` to an object of
1182 type `CURSOR`, which tries to be clever in the event you change the
1183 object. Also, if you use the `X` command to name a substructure and
1184 then move copy it with `G` or `I`, the cursors in the substructure
1185 will follow to the new location.
1186
1187 There are some restrictions. Cursors in empty `LIST`s are okay but
1188 they will not follow the object to new locations. Also this
1189 "following" feature is effective only at the first `G` or `I` after
1190 the `X`. To move the substructure again you have to `X` again.
1191
1192 `I*` is somewhat incompatible with `CURSOR`s. Cursors in Imbedded
1193 structures will sometimes disappear.
1194
1195 `GO` **cursor**  
1196 `Go`  
1197 `GO` takes a *cursor* (normally the `LVAL` of an
1198 `ATOM` previously given as an argument to `CU`) and `GO`es to that
1199 position. If the *cursor* is illegal (not in the current top-level
1200 structure), an error message will be printed and you will remain in
1201 your previous position.
1202
1203 `KC` **atom**  
1204 `Kill Cursor`  
1205 Kill the cursor assigned to *atom*.
1206
1207 `PC`  
1208 `Print Cursors`  
1209 Prints all cursors in the structure to the right of the main cursor.
1210
1211 `PA`  
1212 Prints all cursors in the currently open structure.
1213
1214 #### 3.2.2.8. Breakpoints
1215
1216 `BK` *predicate* *any* ...  
1217 `Breakpoint`  
1218 Inserts a breakpoint "around" the object to the right of the cursor.
1219 Takes any number of arguments. Subsequently, whenever that object
1220 would have heen evaluated, you instead hit a breakpoint function
1221 which:
1222
1223 1.  Evaluates *predicate*. If the value is `FALSE`, evaluation
1224     continues as if there were no breakpoint. If the value is
1225     non-`FALSE`, or `BK` was given no arguments:
1226
1227 2.  Types `**BREAK**`.
1228
1229 3.  For each argument after the first that you gave `BK`, types
1230
1231 *arg = EVAL of arg*
1232
1233 4.  Enters `LISTEN`.
1234
1235 You continue by applying `ERRET` to one argument, just as from an
1236 `ERROR`; the argument's value is ignored.
1237
1238 Breakpoints are implemented by inserting a `BREAKR` (a `PRIMTYPE`
1239 `LIST` with `APPLYTYPE` `FORM`) which consists of the function
1240 `BREAKR` and arguments, including the object breakpointed. A
1241 breakpoint prints as a glyph similar to the cursor:
1242
1243 <strike>`B`</strike> *object*
1244
1245 If the `ATOM` `SHORT-PRINT` is assigned `FALSE`, the actual `BREAKR`
1246 `LIST` is printed.
1247
1248 The breakpoint function returns `EVAL` of the thing it is put
1249 "around", and there are cases where this does not work. There are
1250 always equivalent places that do work.
1251
1252 1.  Breakpoint on the first element of a `FORM` does not work. Put it
1253     on the whole `FORM`.
1254
1255 2.  Breakpoint on a `LIST` which is an argument to a `COND` does not
1256     work. Put it on the first `FORM` in the `LIST`.
1257
1258 `BA` *predicate* *any*  
1259 `Break After`  
1260 Similar to `BK`, but puts the breakpoint *after* the object at the
1261 cursor. Its action is like that of `BK` except that the break occurs
1262 after the object it is on is `EVAL`ed.
1263
1264 This sort of breakpoint prints like the "before" sort. but with the
1265 glyph after the object broken:
1266
1267 object <strike>`B`</strike>
1268
1269 The *predicate* for a `BA` breakpoint may check the value returned by
1270 `EVAL` for the object the hreakpoint is on. This value is assigned by
1271 `BREAKR` to the `ATOM` `VALUE`.
1272
1273 `KT`  
1274 `Kill This`  
1275 Removes the breakpoint (if any) from the object to the right of the
1276 cursor.
1277
1278 `KB`  
1279 `Kill Breakpoints`  
1280 Removes all breakpoints in the currently open object.
1281
1282 #### 3.2.2.9. Edit Monitors
1283
1284 There are several commands in `EDIT` which provide a simple interface
1285 to the "`MONITOR`" `PACKAGE`. These allow placing of monitors on
1286 references to or modifications of `LVAL`s in interpreted Muddle code.
1287
1288 For a more complete discussion of the use of monitors, see section
1289 3.7.
1290
1291 `UM`  
1292 `Use Monitors`  
1293 The `PACKAGE`s for dealing with monitors are not normally loaded in an
1294 initial Muddle, so the `UM` command loads them and makes the three
1295 commands for creating monitors available. The `PACKAGE`s loaded are
1296 "`MONITR`", which is the general monitor `PACKAGE`, and "`EMONIT`",
1297 which is the interface between `EDIT` and "`MONITR`".
1298
1299 `RW` **atom** *predicate* *any* ...  
1300 `Read-write Monitor`  
1301 The most general type of monitor that can be set is a read-write
1302 monitor. It will catch any reference to or attempt to modify the
1303 `LVAL` of the *atom* specified. The restrictions on placement of
1304 breakpoints also apply to monitors, with the addition that a monitor
1305 on an `LVAL` must be placed after that `LVAL` has become `ASSIGNED?`.
1306
1307 The second, third (and so on) arguments to `RW` are the same as those
1308 for `BK`. The *predicate* may be dependent on either the new or old
1309 value of the variable: These are available as the `LVAL`s of `NEWVAL`
1310 and `OLDVAL`, respectively.
1311
1312 When a monitor is triggered, it prints the type of monitor, the
1313 variable being monitored, and any other information requested by the
1314 user, and then calls `LISTEN`.
1315
1316 A monitor prints as yet another glyph:
1317