I have been confused about the following program for a long time. in fact, it's a exercise of SICP 3.2
;exercises 3.2
(define (make-monitored f)
(define (monitor count)
(define how-many-calls
count)
(define reset-count
(set! count 0))
(define (dispatch param)
(cond ((eq? param 'how-many-calls) how-many-calls)
((eq? param 'reset-count) reset-count)
(else (begin (set! count (+ count 1))
(f param)))))
dispatch
)
(monitor 0))
(define (square x) (* x x))
> (define s (make-monitored square))
> (s 10)
100
> (s 'how-many-calls)
0
>
my question is , why the output of "(s 'how-many-calls)" is 0 not 1? can I define a value dynamicly changed? (define how-many-calls count) I want the value of how-many-calls dynamic change when count changes.