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