Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the global-vars Reference Manual, version 1.0.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Thu Mar 11 13:24:07 2021 GMT+0.
• Introduction | What global-vars is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Define efficient global variables in Common Lisp.
;; Similar to defparameter with regard to redefinitions
(define-global-parameter -x- 3)
;; Similar to defvar with regard to redefinitions
(define-global-var -y- 4)
;; ...
(setf -x- 5)
(setf -y- 6)
In Common Lisp, a special variable that is never dynamically bound
typically serves as a stand-in for a global variable. The
global-vars
library provides true global variables that are
implemented by some compilers. An attempt to rebind a global variable
properly results in a compiler error. That is, a global variable
cannot be dynamically bound.
Global variables therefore allow us to communicate an intended usage that differs from special variables. Global variables are also more efficient than special variables, especially in the presence of threads.
[macro] define-global-var
name
value
&optional
documentation
Define a global variable with a compile-time value.
Subsequent redefinitions will not change the value (like defvar
).
The value
argument is evaluated at compile-time. On SBCL, this
permits optimizations based upon the invariant that name
is always
bound.
[macro] define-global-var*
name
value
&optional
documentation
Same as define-global-var
except value
is evaluated at load time,
not compile time.
[macro] define-global-parameter
name
value
&optional
documentation
Same as define-global-var
except subsequent redefinitions will
update the value (like defparameter
).
[macro] define-global-parameter*
name
value
&optional
documentation
Same as define-global-parameter
except value
is evaluated at
load time, not compile time.
global-vars
wraps the following implementation-specific features:
SBCL: sb-ext:defglobal
and sb-ext:define-load-time-global
.
CCL: ccl:defstatic
and ccl:defstaticvar
.
LispWorks: hcl:special-global
, in particular defglobal-parameter
and defglobal-variable
.
For these implementations, rebinding a global variable is a compilation error.
On other implementations, a global variable is implemented as a symbol
macro which expands to a symbol-value
form. Rebinding a global
variable will (unfortunately) not signal an error.
It is recommended to use a naming convention for global variables,
such as -foo-
. This makes it clear that (let ((-foo- 9)) ...)
is a
mistake even if the compiler doesn't catch it.
James M. Lawrence llmjjmll@gmail.com
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The global-vars system |
James M. Lawrence <llmjjmll@gmail.com>
MIT
Define efficient global variables.
1.0.0
global-vars.asd (file)
global-vars.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The global-vars.asd file | ||
• The global-vars/global-vars.lisp file |
Next: The global-vars/global-vars․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
global-vars.asd
global-vars (system)
Previous: The global-vars․asd file, Up: Lisp files [Contents][Index]
global-vars (system)
global-vars.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The global-vars package |
global-vars.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros |
Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Same as ‘define-global-var‘ except subsequent redefinitions will update the value (like ‘defparameter‘).
global-vars.lisp (file)
Same as ‘define-global-parameter‘ except ‘value‘ is evaluated at load time, not compile time.
global-vars.lisp (file)
Define a global variable with a compile-time value.
Subsequent redefinitions will not change the value (like ‘defvar’).
The ‘value’ argument is evaluated at compile-time. On SBCL, this permits optimizations based upon the invariant that ‘name’ is always bound.
global-vars.lisp (file)
Same as ‘define-global-var‘ except ‘value‘ is evaluated at load time, not compile time.
global-vars.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal constants | ||
• Internal macros |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
global-vars.lisp (file)
Previous: Internal constants, Up: Internal definitions [Contents][Index]
global-vars.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F G L |
---|
Jump to: | F G L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | D M S |
---|
Jump to: | D M S |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | +
C |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
+ | |||
+value-key+ : | Internal constants | ||
| |||
C | |||
Constant, +value-key+ : | Internal constants | ||
|
Jump to: | +
C |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | G P S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
G | |||
global-vars : | The global-vars system | ||
global-vars : | The global-vars package | ||
| |||
P | |||
Package, global-vars : | The global-vars package | ||
| |||
S | |||
System, global-vars : | The global-vars system | ||
|
Jump to: | G P S |
---|