![[index]](../icons/index.gif)
Next: The Need for Memory
Up: Changing the State of
Previous: A First Useful Example
Section
motivated the idea of functions with memory;
section
explained how variable definitions and
set! together can achieve the effect of memory. It is now time
to discuss the design of programs with memory.
Designing functions with memory requires three important steps:
- We must determine that a program requires memory.
- We must identify the data that goes into the memory.
- We must understand which of the services are supposed to modify the
memory and which are to use the memory.
The need for the first step is obvious. Once we know that a program
requires memory, we must conduct a data analysis for the program's
memory. That is, we must figure out what kind of data the program puts
into memory and retrieves from there. Finally, we must carefully design
those functions for the program that change the memory. The others are
those that use the variables (without modification); they are typically
designed with one of the recipes we have already discussed.
PLT