末尾呼出し最適化はコンパイル時に行われている。 末尾か?どうかの判定に tail? を定義。 (define (tail? next) (and (pair? next) (eq? (car next) 'return))) next expression が return であれば末尾と判定する。分かりやすい。 理解のために実際に最適化 ON / OFF で何が違うのかを見比べてみる。 ((lambda (a) ((lambda (b) 3))) 4) => (frame () (constant 4 (argument (close (a) (close (b) (constant 3 (return)) (apply)) (apply))))) ;; 最適化 ON (frame () (constant 4 (argument (close (a) (frame (return) (