ステップ実行eval開発中(3)
回り道したが、これを発見した。凄い有難い。
で、問題のコードはcompile.scmのpass1のところにあった。
evalの第一引数のlistの先頭が何なのかをpass1/lookup-headで調べているが、ここが既に実体のマクロやspecial formだった場合にスルーされてしまうのが原因のようだ。
;; Check if the head of the list is a variable, and if so, lookup it. ;; Note that we need to detect the case ((with-module foo bar) arg ...) ;; NB: This isn't a proper fix, for we cannot deal with the situation ;; like nested or aliased with-modules. The Right Thing is to run ;; `pass1 for syntax' on (car PROGRAM) and check the result to see if ;; we need to treat PROGRAM as a special form or an ordinary procedure. ;; It would be a large change, so this is a compromise...
というコメントがあるのが気になるが、とりあえず試してみる。