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


Constant Variables

In Lisp constants are represented by variables which have been marked as being read-only. Any attempt to alter the value of a constant results in an error.

Two of the most commonly used constants are nil and t.

Function: set-const-variable variable &optional read-write
This function defines whether or not the value of the symbol variable may be modified. If read-write is nil or undefined the variable is marked to be constant, otherwise it's marked to be a normal variable. The value returned is variable.

Function: const-variable-p variable
Returns t if the value of the symbol variable may be altered, nil otherwise.

Constants may behave a bit strangely when you compile the program they are used in: the value of the constant is likely to be hardwired into the compiled functions it is used in, and the constant is unlikely to be eq to itself!

The compiler assumes that constant is always the same, whenever it is evaluated. It may even be evaluated more than once. See section Compiled Lisp.

The special form defconst can be used to define constants, see section Defining Variables.


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