Next: , Previous: Modular arithmetic, Up: Efficiency


6.4 Global and Always-Bound variables

— Macro: sb-ext:defglobal name value &optional doc

Defines name as a global variable that is always bound. value is evaluated and assigned to name both at compile- and load-time, but only if name is not already bound.

Global variables share their values between all threads, and cannot be locally bound, declared special, defined as constants, and neither bound nor defined as symbol macros.

See also the declarations sb-ext:global and sb-ext:always-bound.

— Declaration: sb-ext:global

Syntax: (sb-ext:global symbol*)

Only valid as a global proclamation.

Specifies that the named symbols cannot be proclaimed or locally declared special. Proclaiming an already special or constant variable name as global signal an error. Allows more efficient value lookup in threaded environments in addition to expressing programmer intention.

— Declaration: sb-ext:always-bound

Syntax: (sb-ext:always-bound symbol*)

Only valid as a global proclamation.

Specifies that the named symbols is always bound. Inhibits makunbound of the named symbols. Proclaiming an unbound symbol as always-bound signals an error. Allows compiler to elide boundness checks from value lookups.