From: Chip Salzenberg
Subject: Free variables: special or global?
Date:
Message-ID: <25605478.27727@ateng.com>
I've been reading and re-reading the relevant sections in CLtL, and I've
been unable to answer this question.
Consider this code:
(defvar *parrot* "live") ; Global value: "live"
(defun cleese ()
(let ((*parrot* "dead"))
(declare (special *parrot*)) ; Dynamic value: "dead"
(palin)))
(defun palin ()
(print *parrot*)) ; Which will I see??
(cleese) ; What will be printed?
When (cleese) calls (palin), the global value of *parrot* is "live" and the
most recent dynamic value is "dead". Which is printed? And where in CLtL
is this question answered?
I know that if I really want the dynamic value, I can write:
(defun palin ()
(locally (special *parrot*)
(print *parrot*)))
But is the "locally special" necessary, even in the absence of any lexical
bindings? And if it isn't necessary, how can I access the _global_ value
("dead")?
E-Mail or post as you like. I'll summarize mail to the net.
--
You may redistribute this article only to those who may freely do likewise.
Chip Salzenberg at A T Engineering; <ยทยทยทยท@ateng.com> or <uunet!ateng!chip>