(define (make-account balance)
(define (withdraw amount)
(if (>= balance amount)
(sequence (set! balance (- balance amount))
(define (deposit amount)
(set! balance (+ balance amount))
(define (dispatch msg)
(cond ((eq? msg 'withdraw) withdraw)
((eq? msg 'deposit) deposit)
(else (error "Unknown request"
==> (define acc (make-account 100))
==> ((acc 'withdraw) 50)
==> ((acc 'withdraw) 60)
The beauty of this example is that it is the object-oriented programming model distilled right down to its essence. It is succint and to the point. No need to explain about how the compiler is providing syntactic sugar, it's just straight to the bare metal: an object is a collection of functions and data tied together -- a collection of related closures, really.
Additionally, their discussion of the OO paradigm doesn't start with talk of "objects" and "messages", it starts with a well-grounded discussion of the programming model and its implications for the structure of your code. I like that, because that's what Object-oreinted programming is. All that business about objects, messages, and domain models -- that's how we choose to explain object-oriented programming.
There's other great stuff in the book, of course. This is just the bit that I'm loving right now.
For the Lisp-challenged, here's how the code works: make-account is a function that returns an anonymous function, let's call it mike. In the code above, mike is given a name by being bound to acc. The purpose of mike is to dispatch calls to withdraw or deposit. When you call mike, you will pass in either 'withdraw or 'deposit. Based on which of those you pass in, mike will then return one of the mike-local functions withdraw or deposit. This returned function takes a number and returns a number, as shown in the last couple of interpreter commands above.
Coming soon: a couple of more blogs posts inspired by SICP. So why aren't you getting inspired? Read it already.
*Well, other that they are using Scheme.