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

Re: Vectors as functions



Michael Sperber <sperber@informatik.uni-tuebingen.de> writes:

> Lexical binding means you can figure out for each occurrence of a
> name, its binding form.  Consider this (probably not exactly
> CL-correct, but you'll get my drift, I hope):
> 
> (let ((foo 23))
>   (let ((name 'foo))
>     (let ((foo 42))
>       (set name -1)))
>   foo)
> 
> At the place 'foo occurs, there's no way to tell what binding it's
> associated with.  In fact, it may be associated with several different
> bindings at run time, which is a hallmark property of dynamic binding.

In CL, this will not do what I'm guessing you think it will do. In CL
SET changes the symbol-value of a symbol, which is a global property.

Some quotes from the Hyperspec:

(set symbol value) ==  (setf (symbol-value symbol) value)

set cannot change the value of a lexical variable. 

Things like what you hint at can be achieved by judicious use of
(locally (declare (special foo)) ...) or other tricks but then you're
explicitly (ab)using dynamic binding.


-- 
Jane - Daria? Come on, the neighbors are starting to talk.
Daria - Um... good. Soon they'll progress to cave drawings and civilization 
will be on its way.