Lecture: Operational Semantics of Scheme using Substitution

Background Material



In Lecture on Functional Programming we informally provided the semantics for scheme expressions: To evaluate (E1 E2 ... En), recursively evaluate E1, E2,...,En - E1 should evaluate to a function - and then apply the function value of E1 to the arguments given by the values of E2,...,En. In the base case, there are self evaluating expressions (e.g. numbers and symbols). In addition, various special forms such as quote and if must be handled separately.

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.


  1. Lazy Evaluation
  2. Lambda the Magnificent

Lecture Slides

  1. (lambda.ppt, lambda.pdf).


Created: May 22, 2008 (revised May 26, 2010) by jjohnson AT cs DOT drexel DOT DOT edu