Notice that we can give a variable a value in two ways: we can define
it, specifying an initial value, or we can use
set! to change
The difference between these two is that
define allocates storage
for a variable, and gives that storage a name.
set! does not.
You must always
define a variable before
set! will work
For example, if there's not already a definition of
(set! quux 15) is an error, and Scheme will complain.
You're asking Scheme to put (a pointer to) 15 in the storage named by
quux doesn't name any storage yet, so it
makes no sense.
It's rather like we'd told you, "give this to Philboyd" and handed
you some object, (say, a pencil). If you don't know anybody named Philboyd,
you're probably going to complain.
set! is like that. We have
to agree on what the word "Philboyd" means to before it makes sense to
ask you to do something to Philboyd.
define is a way of giving
meaning to an identifier--making it refer to a piece of storage--as
well as giving a value to put there.