Next: Local Variables, Previous: Global Variables, Up: Variables [Contents][Index]
12.2 Variables that Never ChangeIn Emacs Lisp, certain symbols normally evaluate to themselves. These include nil
and t
, as well as any symbol whose name starts with ‘:’ (these are called keywords). These symbols cannot be rebound, nor can their values be changed. Any attempt to set or bind nil
or t
signals a setting-constant
error. The same is true for a keyword (a symbol whose name starts with ‘:’), if it is interned in the standard obarray, except that setting such a symbol to itself is not an error.
(setq nil 500) error→ Attempt to set constant symbol: nil
function returns t
if object is a symbol whose name starts with ‘:’, interned in the standard obarray, and returns nil
otherwise.
These constants are fundamentally different from the constants defined using the defconst
special form (see Defining Global Variables). A defconst
form serves to inform human readers that you do not intend to change the value of a variable, but Emacs does not raise an error if you actually change it.
A small number of additional symbols are made read-only for various practical reasons. These include enable-multibyte-characters
, most-positive-fixnum
, most-negative-fixnum
, and a few others. Any attempt to set or bind these also signals a setting-constant
error.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4