invert_by_lu does not work as expected



On Wed, 2012-01-11 at 17:38 +0000, Rupert Swarbrick wrote:
   . . .
> has the same effect. I've just been staring at CLHS and can't find the
> relevant passage unfortunately. I think I want to say something like
> "LET binds a variable X to a new lexical binding, unless it already had
> a dynamic binding in which case it binds it dynamically", but I'm not
> sure where to look.

This from the CLHS entry for "Declaration Special" may be relevant (the
part after my elipsis is to the point):

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.
   . . .
When used in a proclamation, a special declaration specifier applies to
all bindings as well as to all references of the mentioned variables.
For example, after

 (declaim (special x))

then in a function definition such as

 (defun example (x) ...)

the parameter x is bound as a dynamic variable rather than as a lexical
variable.
==============================================================

Section 5.2.2, "Lambda Expressions", pg. 77 of CLtL2 has this to say
about binding of required parameters of the lambda list of a lambda
expression when it is applied to arguments:

Here, and in general, the parameter is bound as a lexical variable
unless a declaration has been made that it should be a special binding.
See defvar, proclaim, and declare.
==============================================================

It would seem that some but not all special declarations can override
the default bindings of a variable as lexical.

-- 
Bill Wood