Practice 4.7
let* 中的变量约束是在同一个环境中完成 而嵌套的let每个约束都是新环境,每个后继约束创建的新环境是前一个环境的子环境, 它继承了前一个的所有约束,所以嵌套的let最后的body的执行环境和let*的body 的执行环境是等价的
(define (let*->nested-lets exp)
(let ((bind-list (let*-binds exp))
(body (let*-body exp)))
(if (null? bind-list)
body
(make-let (car bind-list)
(let*->nested-lets (make-let* (cdr bind-list) body))))))
(define (let*? exp)
(tagged-list? exp 'let*))
(define (let*-binds exp)
(cadr exp))
(define (let*-body exp)
(caddr exp))
(define (make-let* bind-list body)
(list 'let* bind-list body))