[pro] couple questions about dynamic bindings

Martin Simmons martin at lispworks.com
Mon Dec 27 16:32:10 UTC 2010


>>>>> On Sun, 26 Dec 2010 16:04:06 -0800, Greg Gilley said:
> 
> There are some tests in the common-lisp test suite with dynamic binding that
> I don't understand. If someone could help shed some light on them I'd
> appreciate it.
> 
> progv makes it's arguments special. I don't understand how they can be a
> different special than the one declared in the let. I'd love an explanation.
> 
> (let ((x 0))
>     (declare (special x))
>     (progv '(x) ()
>       (boundp 'x))) ==> NIL
> 
> (let ((x 0))
>     (declare (special x))
>     (progv '(x) () (setq x 1))
>     x) ==> 0

The type of binding is the same, but the real power of progv is that it
evaluates the list of variables, unlike let where the variable names are fixed
when the code is created.  See also the difference between set and setq.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/




More information about the pro mailing list