3 ms·
A global variable is a variable with global scope, meaning that it is visible and accessible throughout the program, unless shadowed. Emacs added lexical scopi
by sillysaurus3 10y ago
A global variable is a variable with global scope, meaning that it is visible and accessible throughout the program, unless shadowed.
Emacs added lexical scoping several years ago. When a global variable is declared in emacs using defvar, in addition to becoming globally accessible, the symbol is also flagged as special. This causes it to use dynamic binding whenever it is `let`-bound, even if lexical scoping is in effect.
I pointed out dynamic binding in order to call attention to a technique that allows global variables to be composed into large-scale systems without being hindered by the problems traditionally associated with global state. But if you'd like more precision, feel free to ask.