From: ···@lmi-angel.UUCP
Subject: Special variables in Common Lisp
Date: 
Message-ID: <145@lmi-angel.UUCP>
Oops, I forgot about the screw case of special variables.  I said that it
was lexically apparent if a variable is special, but of course a globally
special variable (whose proclamation of being special need not be lexically
apparent) can be the parameter in a lambda list or bound in LET and friends.
However, there are some heuristics.

* The least convention-specific clue is binding a variable, but then not
  using it anywhere inside the lexical scope of the binding.

In other words, why would anybody do

 (let ((lose-p nil))
   (save-the-world))

unless LOSE-P was a special variable which evidently affected the behavior
of the SAVE-THE-WORLD function ?  If the variable LOSE-P were not special,
the compiler would probably warn about the useless binding.

* There is, of course, the *foo* convention.

So somebody who proclaims LOSE-P special and the writes stuff like

  (defun mumble (n lose-p)
    (frob n) ; and let's say that LOSE-P affects FROB, too
    (glork (+ n 1) lose-p))

will foil a reasonable code reader, if the reader can't figure out whether
LOSE-P is special with an implementation tool.

Other musings:

There is no VARIABLE-GLOBALLY-SPECIAL-P function in Common Lisp, but there
ought to be, at least in a language tools package (or maybe that mysterious
SYS package fleetingly mentioned in the CLtL).

Compiled functions which make use of local special declarations should
record a list of what variables were declared special locally, so that the
debugger's version of the evaluator can catch references to such variables,
and make clear to the user what kind of variable he is dealing with.
-- 
Robert P. Krajewski
Internet/MIT: ···@MC.LCS.MIT.EDU
        UUCP: ...{cca,harvard,mit-eddie}!lmi-angel!rpk