Go to the first, previous, next, last section, table of contents.

Variable Binding Again

So far, I've sometimes casually talked about variables holding values, but that's not quite right. Variables are bound to storage, and storage holds values.

I've also sometimes casually talked about fetching "the value of a variable," but that's really just a shorthand for fetching the value of the current binding of a variable, from the current environment.

Consider what happens when we define a variable foo with the definition (define foo 10). We can draw the binding of the variable in this way:

 foo |  *--+---> 10

When speaking precisely, we say that the variable foo is bound to the memory location represented by the box on the left. Binding just means making an association between a name and something. (There are several senses of "binding"---it's a very general word--but in this book, I'm generally talking about associating program variables with actual storage.)

For brevity, we refer to the location as the variable's binding, but binding is really the relationship between the name and the storage it names.

In Scheme terminology, we talk about "bindings" as distinct from variables, because they are two different things. This is true in most other languages as well (e.g., C and Pascal), but usually people don't make the distinction explicit. They'll refer to a program variable as a variable, but they'll also call the storage allocated for a particular instance of that variable a "variable." Usually, experienced programmers aren't confused by this.

In this book, I try to be a little more precise, because the distinction between variables and bindings is especially important in discussing advanced topics that will come up later. For now, rest assured that there's nothing really unusual here--when I distinguish between variables and bindings, that's applicable to most programming languages, not just Scheme. I'm just giving a name to something you probably already know.

(So far, we haven't seen anything really special about Scheme variables and bindings, except that the values in bindings are always pointers.)

Go to the first, previous, next, last section, table of contents.