Next: Higher-order Arglists, Previous: Lambda-lifting, Up: Principles of Compilation [Contents][Index]
As the scheme do-construction is compiled into C for, but for cannot occur in all places in C (it is a statement), then if the do in a scheme procedure occurs in a place which will not be a statement in C, the whole do-term is lifted out into a new top-level procedure analogously to lambda-lifting. Any statement-lifted parts of some procedure foo are called foo_auxn, where n is a number.
The special C-ish procedure **return** is pushed into a scheme term as far as possible to extend the scope of statements in the resulting C program. For example,
(define foo (lambda (x y) (if x (+ 1 y) (+ 2 y)) ))
is converted to
(define foo (lambda (x y) (if x (**return** (+ 1 y)) (**return** (+ 2 y))) ))
Immediate tailrecursion (foo calling foo tailrecursively) is recognized and converted into an assignment of new values to args and a jump to the beginning of the procedure body.