GNU Info

Info Node: (librep.info)Modules and Special Variables

(librep.info)Modules and Special Variables


Prev: Module Loading Up: Modules
Enter node , (file) or (file)node

Modules and Special Variables
-----------------------------

   As described earlier, the `defvar' special form may be used to
create variables that are scoped dynamically, known as special
variables, see Note: Defining Variables. Due to their dynamic scope,
special variables do not fit well with the lexically scoped module
system described here.

   As a result of this mismatch, special variables are stored in a
separate namespace. This means that modules defining special variables
must take the necessary steps to avoid the names of these variables
clashing with those declared in other modules(1).

   In fact, it is often advisable to avoid using special variables as
much as possible, especially when writing modules of Lisp code. An
alternative method of creating dynamically scoped variables is to use
fluid variable objects. These use first class Lisp objects to represent
anonymous dynamically scoped variables. Since they are just Lisp
objects, they may be stored in lexically scoped variables--this gives
the benefits of both lexical (i.e. encapsulation) and dynamic scoping.
Note: Fluid Variables.

   ---------- Footnotes ----------

   (1) The usual convention is to prefix the variable name with a
unique string derived from the module name.


automatically generated by info2www version 1.2.2.9