Page:AIM-453.djvu/59

 {LABELS} Pages 29, 59

This technique can be generalized to allow the definition of recursive local procedures. (Although the Y-operator discussed in {Note Y-operator} can be used to implement recursive local procedures, it is extremely painful to construct several mutually recursive procedures. Although mutually recursive procedures can be theoretically eliminated (by procedure integration), this process destroys the conceptual structure of the program.)

Consider writing a procedure to construct the reverse of a given list:

The procedure REVERSE1 is irrelevant to the outside world; we would like to hide it inside REVERSE.

Let us invent a new construction to permit the definition of local procedure definitions with names:

means the value of body when evaluated in an environment where the specified procedure definitions are available. For example:

The same trick works for LABELS as for the top level: when LOOKUP1 has found a -defined function, it has the correct environment in hand for constructing a &PROCEDURE-object. We need only add a test in EVAL for the LABELS construct, and arrange for the appropriate &LABELED-objects to be constructed (see Figure N5).