Pascal Costanza <email@example.com> wrote:
| Ari Johnson wrote:
| > Please explain how it was incorrect, if you have the time. Thanks. :)
| He already did. When you change the value of a global variable via setq,
| all threads will see the new value.
Well, close, but... That's only correct if the global variable has not
yet been dynamically bound in the current thread. If the global variable
*has* been dynamically bound in the current thread, then a SETQ of the
global variable from within that thread will only change the value seen
within that thread.
Conversely, if the global variable *has* been dynamically bound in the
current thread, say, thread "X", then a SETQ of the global variable from
within some other thread when *not* bound will only change the value
seen within that and other threads in which it hasn't been bound, but
*not* the value seen within "X" and other threads in which *has* been
This is why (in threaded implementations) you'll often see functions
that start off with:
(let ((*foo* *foo*)
;; *FOO* and *BAR* are now protected from SETQs in other
;; threads, and vice versa.
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607