DEFVAR

Defines symbol in global scope as variable. The forms DEFVAR and DEFPARAMETER are similar, and both have the purpose to make the LISP program more human-readable. There is no difference between the symbols defined by DEFVAR, DEFPARAMETER or just with SETQ.

The idea is that the symbol introduced with DEFVAR somewhere near the beginning of the code will be further used as global variable in the LISP program.

DEFVAR form needs one argument, and can have 2 more optional paramterers. The first parameter must be a symbol. Symbols from base package (reserved), or symbols defined as constants will not be allowed. Second, optional argument is evaluated, and will serve as the initialization value for the new variable. In case that the symbol is already bound, the DEFVAR will have no effect - the value will not be overwritten. Third, also optional argument is a description string.

>(defvar counter 0 "global object counter")   
COUNTER

See also: DEFPARAMETER, SETQ, DEFCONSTANT