<< Previous exercise (5.42) | Index | Next exercise (5.44) >>


 ;; we just need use scan-out-defines here change lambda-body to 
 ;; equivalent expression. 
 (define (compile-lambda-body exp proc-entry ct-env) 
   (let ((formals (lambda-parameters exp))) 
       (make-instruction-sequence '(env proc argl) '(env) 
           (assign env (op compiled-procedure-env) (reg proc)) 
           (assign env 
                   (op extend-environment) 
                   (const ,formals) 
                   (reg argl) 
                   (reg env)))) 
         (scan-out-defines (lambda-body exp)) 
         'val 'return 
         (extend-ct-env ct-env formals))))) 


I needed to make two changes to the original scan-out-defines:

  1. Instead of transforming to a let expression (as implied by 4.1.6), I
     transformed directly to a lambda expression. Alternatively, I could
     have added let support to the compiler.

  2. *unassigned* needed to be double quoted, i.e.:


     otherwise, when the compiler analyzed the lambda expression it would
     interpret *unassigned* as a variable name.