In this lecture we will further discuss the semantics of scheme expressions. We will begin with a simple model, called the substitution model, where a function application corresponds to substituting the argument expressions into the formal parameters of the function body. The substitution process can proceed in different orders - scheme uses applicative order, where the arguments are fully evaluated prior to substitution. Other possibilities exist - for example, the arguments can be immediately substituted and then only further expanded when needed (normal order). The substitution model of function application is formally investigated using the lambda calculus, and the second part of the lecture will introduce the lambda calculus. The Church-Rosser theorem states that these two approaches will give the same result when the evaulation process terminates in both cases; however, there are scenarios where applicative order will not return a result, while normal order will return a result.
We begin our study with an implementation of streams using delayed evaluation with thunks. Then a modified scheme interpreter is presented that uses normal order (lazy evaluation). In this version streams and lists are identical and we do not need special support for streams.