SICP 読み (345) 5.5 翻訳系
昨晩の 5.43 の解については問題ないと判断。次の問題が済んだらラスイチか。流して読めない濃さに見えます。進捗が遅いのは下手にスルーしたら永遠に進みそうにない、という脅迫観念から来るのかも、と思わざるを得ない今日この頃。
問題 5.44
とりあえず、問題 5.38 な compile が以下
(define (compile exp target linkage) (cond ((self-evaluating? exp) (compile-self-evaluating exp target linkage)) ((quoted? exp) (compile-quoted exp target linkage)) ((variable? exp) (compile-variable exp target linkage)) ((assignment? exp) (compile-assignment exp target linkage)) ((definition? exp) (compile-definition exp target linkage)) ((if? exp) (compile-if exp target linkage)) ((lambda? exp) (compile-lambda exp target linkage)) ((begin? exp) (compile-sequence (begin-actions exp) target linkage)) ((cond? exp) (compile (cond->if exp) target linkage)) ((eq? '+ (car exp)) (compile-plus exp target linkage)) ((eq? '* (car exp)) (compile-mul exp target linkage)) ((eq? '= (car exp)) (compile-equal exp target linkage)) ((eq? '- (car exp)) (compile-minus exp target linkage)) ((application? exp) (compile-application exp target linkage)) (else (error "Unknown expression type -- COMPILE" exp))))
これは 5.5.6 のテーマで解決可能な気がします。てー事は前の問題でスルーした_let で束縛した手続きを lexical-address で参照_な実装が必要なカンジ。これはちょっと違う意味な面白さがあるんじゃないでしょうか。何と言えば良いのかなぁ。
gcc はグローバル変数とか stacic な変数をどうやって表現しているか、と言えば良いのかなぁ。仕方が無いので一旦戻りたいと思います。
# 見といて良かった