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


In Lisp, a symbol can have a value attached to it just as it can have a function definition attached to it. The two are different. The function definition is a set of instructions that a computer will obey. A value, on the other hand, is something, such as number or a name, that can vary (which is why such a symbol is called a variable). The value of a symbol can be any expression in Lisp, such as a symbol, number, list, or string. A symbol that has a value is often called a variable.

A symbol can have both a function definition and a value attached to it at the same time. The two are separate. This is somewhat similar to the way the name Cambridge can refer to the city in Massachusetts and have some information attached to the name as well, such as "great programming center".

Another way of thinking of this is to imagine a symbol as being a chest of drawers. The function definition is put in one drawer, the value in another, and so on. What is put in the drawer holding the value can be changed without affecting the contents of the drawer holding the function definition, and vice-versa.

The variable fill-column illustrates a symbol with a value attached to it: in every GNU Emacs buffer, this symbol is set to some value, usually 72 or 70, but sometimes to some other value. To find the value of this symbol, evaluate it by itself. If you are reading this in Info inside of GNU Emacs, you can do this by putting the cursor after the symbol and typing C-x C-e:


After I typed C-x C-e, Emacs printed the number 72 in my echo area. This is the value for which fill-column is set for me as I write this. It may be different for you in your Info buffer. Notice that the value returned as a variable is printed in exactly the same way as the value returned by a function carrying out its instructions. From the point of view of the Lisp interpreter, a value returned is a value returned. What kind of expression it came from ceases to matter once the value is known.

A symbol can have any value attached to it or, to use the jargon, we can bind the variable to a value: to a number, such as 72; to a string, "such as this"; to a list, such as (spruce pine oak); we can even bind a variable to a function definition.

A symbol can be bound to a value in several ways. See section Setting the Value of a Variable, for information about one way to do this.

Notice that there were no parentheses around the word fill-column when we evaluated it to find its value. This is because we did not intend to use it as a function name. If fill-column were the first or only element of a list, the Lisp interpreter would attempt to find the function definition attached to it. But fill-column has no function definition. Try evaluating this:


You will produce an error message that says: 

Symbol's function definition is void: fill-column

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