Lecture: Lazy Evaluation
- Bound and free variables and scope rules (see chapter 5 of the text)
- Review evaluation rules of scheme and streams (see
lecture on scheme interpreter)
- Chapters 10 (sec. 4) of the text and
section 4.2 of
In this lecture we revisit alternative orders of function evaluation and
streams. We examine the benefits of normal order over applicative order.
a modified version of scheme that uses normal order and show how to modify the
metacircular interpreter to support lazy evaluation. While applicative
order is more commonly used, due to its efficiency, a technique called
memoization can be used to improve performance of languages with normal order.
In the interpreter with normal order evaluation lists and streams are identical.
Even more important than "normal order" scheme and lazy evaluation is the notion
that interpreters can be used to investigate alternative language design
choices and language implementations.
- Review substitution model of computation and applicative vs.
normal order of evaluation
- Review streams
- Implementation of streams (modification of metacircular interpreter)
- Variant of scheme with lazy evaluation
- Modification of metacircular interpreter to support lazy evaluation
Created: May 20, 2009 (modified April 19, 2012) by jjohnson AT cs DOT drexel DOT DOT edu
- Trace stream example using the modified interpreter with support
for streams (see solutions to practice exercise 3)
- Run modified interpreter (lazy evaluation) on some examples where
order of evaluation matters.
- Study and run memoization code for fibonacci.