www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_25.html   search  
Buy the book!

Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7.2 Error Message for a Symbol Without a Value

If you attempt to evaluate a symbol that does not have a value bound to it, you will receive an error message. You can see this by experimenting with our 2 plus 2 addition. In the following expression, put your cursor right after the +, before the first number 2, type C-x C-e:

(+ 2 2)

In GNU Emacs 21, you will create a `*Backtrace*' buffer that says:

---------- Buffer: *Backtrace* ----------
Debugger entered--Lisp error: (void-variable +)
---------- Buffer: *Backtrace* ----------

(As with the other times we entered the debugger, you can quit by typing q in the `*Backtrace*' buffer.)

This backtrace is different from the very first error message we saw, which said, `Debugger entered--Lisp error: (void-function this)'. In this case, the function does not have a value as a variable; while in the other error message, the function (the word `this') did not have a definition.

In this experiment with the +, what we did was cause the Lisp interpreter to evaluate the + and look for the value of the variable instead of the function definition. We did this by placing the cursor right after the symbol rather than after the parenthesis of the enclosing list as we did before. As a consequence, the Lisp interpreter evaluated the preceding s-expression, which in this case was the + by itself.

Since + does not have a value bound to it, just the function definition, the error message reported that the symbol's value as a variable was void.

In GNU Emacs version 20 and before, your error message will say:

Symbol's value as variable is void: +

The meaning is the same as in GNU Emacs 21.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003