[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Locally



    (locally (declare (special foo))
      (let ((foo 3))
        (print foo)))

    In NIL, Vaxlisp and HPCommon Lisp this form executes smoothly and
    prints "3".  Either all three implementations are wrong, or
    the documentation is confusing (to me.)
    ...
    I think that Locally (declae (special foo)) should affect
    every binding and reference to foo within the body of the locally.
    This would make it behave like a lexically scoped version of "proclaim".

I think that all three implementations are right, but not for the reason
you suspect.  The binding of FOO within the LET is a lexical binding,
because the external special declaration has no effect on this binding.
This lexical binding is what the reference to FOO in the PRINT form
sees.  This new binding shadows the SPECIAL declaration for references
lexically within the LET.  See the example on page 158, which is almost
exactly the same case.

The current rules covering special declarations are strange, at best,
but I think the manual is reasonably clear, under the circumstances.
There is an example covering the case that confused you.  I admit that
the example is a bit hard to follow...

-- Scott