Jump to content

Page:AITR-474.djvu/63

From Wikisource
This page has been proofread, but needs to be validated.
53

transform it into:

((LAMBDA (Q1)
         (IF (HAIRYP X)
             (BLOCK (PRINT '|Here is some hair:|)
                    (Q1)
                    (PRINT '|End of hair.|))
             (BLOCK (PRINT '|This one is bald:|)
                    (Q1)
                    (PRINT '|End of baldness:|))))
 (LAMBDA () (PRINT X)))

This is similar to the call-by-name trick used in writing macro rules.

A more general transformation would detect nearly common subexpressions as follows:

((LAMBDA (Q1)
         (IF (HAIRYP X)
             (Q1 '|Here is some hair:|
                 '|End of hair.|)
             (Q1 '|This one is bald:|
                 '|End of baldness.|)))
 (LAMBDA (Q2 Q3)
         (BLOCK (PRINT Q2) (PRINT X) (PRINT Q3))))

In this way we can express the notion of subroutinization. {Note Subroutinization}

We point out these possibilities despite the fact that they have not been implemented in RABBIT because the problem of isolating common subexpressions seems not to have been expressed in quite this way in the literature on compilation strategies. We might speculate that this is because most compilers which use complex optimization strategies have been for ALGOL-like languages which do not treat functions as full-fledged data objects, or even permit the writing of "anonymous" functions in functions calls as LISP does.

RABBIT does perform folding on constant expressions [Allen and Cocke]; that is, any combination whose function is a side-effect-less MacLISP primitive