10.1 Packaging procedures and state

Recall our counter from Example 9.1

(define (update-counter!) (set! counter (+ counter 1)) counter)

Every time an application of update-counter! is evaluated, we expect to obtain a value one larger than the previous application. This only works, however, if there are no other evaluations that modify the counter variable. Hence, we can only have one counter: there is only one counter place in the global environment. If we want to have a second counter, we would need to define a new variable (such as counter2, and implement a new procedure, update-counter2!, that is identical to update-counter!, but manipulates counter2 instead. For each new counter, we would need a new variable and a new procedure.