1 Exercise 3.41. Ben Bitdiddle worries that it would be better to implement the bank account as follows (where the commented line has been changed):
3 (define (make-account balance)
4 (define (withdraw amount)
5 (if (>= balance amount)
6 (begin (set! balance (- balance amount))
9 (define (deposit amount)
10 (set! balance (+ balance amount))
12 ;; continued on next page
14 (let ((protected (make-serializer)))
16 (cond ((eq? m 'withdraw) (protected withdraw))
17 ((eq? m 'deposit) (protected deposit))
19 ((protected (lambda () balance)))) ; serialized
20 (else (error "Unknown request -- MAKE-ACCOUNT"
24 ;; because allowing unserialized access to the bank balance can result in anomalous behavior. Do you agree? Is there any scenario that demonstrates Ben's concern?