Specifies that all of the vars named are dynamic. This specifier affects variable bindings and affects references. All variable bindings affected are made to be dynamic bindings, and affected variable references refer to the current dynamic binding.
In the below example, the binding of the parameter
*mod* is visible to
hack1, but the binding of
thing is not.
A special declaration does not affect inner bindings of a var; the inner bindings implicitly shadow a special declaration and must be explicitly re-declared to be special. special declarations never apply to function bindings.
special declarations can be either bound declarations, affecting both a binding and references, or free declarations, affecting only references, depending on whether the declaration is attached to a variable binding.
(declaim (special x))
then in a function definition such as
(defun example (x) ...)
x is bound as a dynamic variable rather than as a lexical variable.
(bar 'first 'second)
The reference to
*foo* in the first line of this example is not special even though there is a special declaration in the second line.
(declaim (special *prosp*))
(defparameter *prosp* 1)
(defparameter *reg* 1)
In the example below, the binding of
*prosp* is special due to the preceding proclamation, whereas the variable
*reg* is lexical.
In the contorted code above, the outermost and innermost bindings of
y are dynamic, but the middle binding is lexical. The two arguments to
+ are different, one being the value, which is
3, of the lexical variable
y, and the other being the value of the dynamic variable named
y (a binding of which happens, coincidentally, to lexically surround it at an outer level). All the bindings of
x and references to
x are dynamic, however, because of the proclamation that
x is always special.