SICP

1.1.5 The Substitution Model for Function Application
We must evaluate the function expression to get the function to be applied, and we must evaluate the argument expressions to get the arguments.
image.png
替代模型,推理函数的过程

The process we have just described is called the substitution model for function application. It can be taken as a model that determines the meaning of function application
函数应用的替代模型,该模型用于确定函数应用的意义

In practice, the substitution is accomplished by using a local environment for the parameters.
The substitution model is only the first of these models—a way to get started thinking formally about the evaluation process. In general, when modeling phenomena in science and engineering, we begin with simplified, incomplete models.
替换是通过使用参数的局部环境来完成的。
替代模型是是一种开始正式思考评估过程的途径。一般来说,在对科学和工程中的现象建模时,我们从简化的、不完整的模型开始。

This alternative fully expand and then reduce evaluation method is known as normal-order evaluation, in contrast to the evaluate the arguments and then apply method that the interpreter actually uses, which is called applicative-order evaluation. It can be shown that, for function applications that can be modeled using substitution (including all the functions in the first two chapters of this book) and that yield legitimate values, normal-order and applicative-order evaluation produce the same value.
JavaScript uses applicative-order evaluation, partly because of the additional efficiency obtained from avoiding multiple evaluations of expressions such as those illustrated with 5 + 1 and 5 * 2 above and, more significantly, because normal-order evaluation becomes much more complicated to deal with when we leave the realm of functions that can be modeled by substitution.
应用次序 遇到表达式就先运算求值,也就是先求参数值,再用参数值应用函数
正常次序 则是先展开,展开到最后只有运算组合了再求值

应用次序 (Applicative order)

“应用次序”(或“最左最内”)求值称呼函数的实际参数按可归约表达式的后序遍历从左至右的求值的策略。不像传值调用,应用次序求值尽可能的在应用函数之前归约函数体内的项。

正常次序 (Normal order)

“正常次序”(或“最左最外”)求值是总是归约的最外可归约式,在求值函数的实际参数之前应用函数的求值策略。它不同于传名调用,传名调用不进入未应用的函数体内求值。
很明显,JS使用的是 applicative-order evaluation
部分原因是由于避免对表达式进行多次求值
因为当我们离开可以用替换来建模的函数领域时,正态序求值变得更加复杂。