[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Locally
What does the form:
(locally (declare (special foo))
(let ((foo 3))
(print foo)))
do?
On P.156 it says that Locally "does not bind any variables and therefore
cannot be used meaningfully for declarations of variable bindings".
This would imply that the FOO bound by the LET is not affected by the
LOCALLY and that this form should be an error because the SPECIAL
reference to FOO in (print foo) is not bound by the lexical binding
of 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.)
Personally I think that the implementations are correct, since
the other interpretation implies that the let in:
(locally (declare (special foo))
...
(let ((foo ...))
...))
Cannot ever be meaningfu, since the variable foo is REFERENCED as
a special, but bound as a lexical.
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".
In any case the documentation seems ambiguous or wrong.