gnu.org (original) (raw)
Next: Functions, Previous: Control Structures, Up: Emacs Lisp [Contents][Index]
12 Variables
A variable is a name used in a program to stand for a value. In Lisp, each variable is represented by a Lisp symbol (see Symbols). The variable name is simply the symbol’s name, and the variable’s value is stored in the symbol’s value cell10. See Symbol Components. In Emacs Lisp, the use of a symbol as a variable is independent of its use as a function name.
As previously noted in this manual, a Lisp program is represented primarily by Lisp objects, and only secondarily as text. The textual form of a Lisp program is given by the read syntax of the Lisp objects that constitute the program. Hence, the textual form of a variable in a Lisp program is written using the read syntax for the symbol representing the variable.
- Global Variables
- Variables that Never Change
- Local Variables
- When a Variable is Void
- Defining Global Variables
- Tips for Defining Variables Robustly
- Accessing Variable Values
- Setting Variable Values
- Running a function when a variable is changed.
- Scoping Rules for Variable Bindings
- Buffer-Local Variables
- File Local Variables
- Directory Local Variables
- Connection Local Variables
- Variable Aliases
- Variables with Restricted Values
- Generalized Variables
- Multisession Variables
Footnotes
(10)
To be precise, under the default dynamic scoping rule, the value cell always holds the variable’s current value, but this is not the case under the lexical scoping rule. See Scoping Rules for Variable Bindings, for details.