Page:AITR-474.djvu/48

From Wikisource
Jump to navigation Jump to search
This page needs to be proofread.
((LAMBDA (V R) (IF V V (R))) 
 a 
 (LAMBDA () ((LAMBDA (V R) (IF V V (R))) 
            b
            (LAMBDA () ((LAMBDA (V R) (IF V V (R))) 
                       c   
                       (LAMBDA () 'NIL-))))))

Then we might imagine the following (slightly contrived) compilation scenario.

First, for expository purposes, we shall rename the variables in order to be able to distinguish them.

((LAMBDA (V1 R1) (IF V1 V1 (R1))) 
 a
 (LAMBDA () ((LAMBDA (V2 R2) (IF V2 V2 (R2)))
             b
             (LAMBDA () ((LAMBDA (V3 R3) (IF V3 V3 (R3))) 
                        c 
                        (LAMBDA () 'NIL))))))

we shall assign a generated name to each LAMBDA-expression, which we shall notate by writing the name after the word LAMBDA. These names will be used as tags in the output code.

((LAMBDA namel (V1 R1) (IF V1 VI (R1))) 
 a (LAMBDA nameZ () ((LAMBDA name3 (V2 R2) (IF V2 V2 (R2)))
                     b 
                     (LAMBDA name4 () ((LAMBDA name5 (V3 R3) 
                                               (IF V3 V3 (R3))) 
                                 c
                                 (LAMBDA name6 () 'NIL))))))

Next, a simple analysis shows that the variables R1, R2, and R3 always denote the LAMBDA-expressions named name2, name4, and name6, respectively. Now an optimizer might simply have substituted these values into the bodies of name1, name3, and name5 using the rule of beta-conversion, but we shall not apply that technique here. Instead we shall compile the six functions in a straightforward manner. we make use of the additional fact that all six functions are closed in identical