#1
Programming with State & Golden Ages
#2
One-Slide Summary
- The substitution model for evaluating Scheme does
not allow us to reason about mutation. In the environment model:
- A name is a place for storing a value. define, cons
and function application create places. set! changes the value in a place.
- Places live in frames. An environment is a frame and
a pointer to a parent frame. The global environment has no parent.
- To evaluate a name, walk up the frames until you
find a definition.
- A golden age is a period when knowledge or quality
increases rapidly.
#3
Outline
- Names and Places
- set! and friends
- Environment Model
- Golden Ages
- Interested in random weekly emails about
available CS 150 tutoring? Send email to the course staff (or me) to get on that list.
- There will not be normally scheduled lab hours or
- ffice hours over spring break.
- Your Exam 1 grade will be visible on the
Automatic Adjudication website.
#4
Evaluation Rule 2: Names
If the expression is a name, it evaluates to the value associated with that name.
> (define two 2) > two 2
From Lecture 3:
This is called the substitution model. You can reason about Scheme expressions by substituting the definition in whenever it is used.
#5
Names and Places
- A name is not just a value, it is a
place for storing a value.
- define creates a new place,
associates a name with that place, and stores a value in that place
x: 3 (define x 3)
#6