== avisiblenetwork ==
seeing the invisible

Substitution for Procedures

Substitution is a convenient way to think about how procedures operate, especially compound procedures that we ourselves define. In the previous post, I illustrated how the function of f was under the hood by writing out all of its parts: (+ (* (+ 3 1) (* 4 2)) (* (+ 3 1) (* 4 2))). This is what substitution offers. One starts with retrieving the procedure, in this case, sum-of-product, and then product. Then, replace the parameters with the arguments, in this case 3 and 4, and then evaluate all components.

This is considered simple and conceptual, and not how interpreters actually work. However, this gives meaning to the procedure. By adding arguments to the function, it allows the procedure to instantiate itself, and is called into the world.

We also need to consider the different orders in which to evaluate procedures. The normal-order evaluation would evaluate arguments only when applying the procedure, as opposed to the applicative-order evaluation where the arguments are evaluated first before applying the procedure. How I described the inner-workings of function f is considered the normal-order evaluation, where the procedures were expanded out and then the evaluation took place. Each method has its own advantages and disadvantages, which will be explored further in later chapters.