仕事が忙しくて終電近い日々が続いてますが、なんとか1ページは続けています。
1.1.3 組み合わせの評価
- 組み合わせを評価するには次のことを行う
- 組み合わせの部分式を評価する
- 最左部分式の値である手続き(演算子)を、残りの部分式の値である引数(被演算子)に作用させる
- 数字列は、その表す数値とする
- 基本演算子の値は、対応する演算を実行する機械命令の列とする
- それ以外の名前の値は、その環境で名前と関連づけられたオブジェクトとする
「列」がピンと来ないので、原書に戻る。
- To evaluate a combination, do the following:
- Evaluate the subexpressions of the combination.
- Apply the procedure that is the value of the leftmost subexpression(the operator) to the arguments that are the values of the other subexpressions(the operands)
- the values of numerals are the numbers that they name,
- the values of built-in operators are the machine instruction sequences that carry out the corresponding operations, and
- the values of other names are objects associated with those names in the environment.
「機械命令の列」は「machine instruction sequences」。これなら理解出来る。
上の評価規則が定義は扱わないことに注意してほしい。例えば(define x 3)の評価はdefineを二つの引数(一方は記号xで、もう一方は3)に作用させるのではない。defineの目的はxを値に対応づけることでしかない。(つまり、(define x 3)は組み合わせではない)
このような一般評価規則の例外を特殊形式(special forms)という。defineはこれまでに現れたただ一つの特殊形式だが、他のものにもすぐ出会う。各特殊形式はそれ自身の評価規則を持つ。(それぞれに特有の評価規則のある)いろいろな種類の式でプログラム言語の構文規則が出来ている。他の多くのプログラム言語を比べ、Lispはとても単純な構文規則を持っている。つまり、式の評価規則は単純な一般規則と少数の特殊形式に特価した規則で出来ている。
すんなり理解は出来たけど、重要と思われるので写経しました。