Subject: Re: Implementation of LET with special variables
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 03 Jun 2004 05:19:38 -0500
Newsgroups: comp.lang.lisp
Message-ID: <KqydnW2PYqSnZiPdRVn-jw@speakeasy.net>
Tim Bradshaw <tfb+google@tfeb.org> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) wrote:
| > This is why (in threaded implementations) you'll often see functions
| > that start off with:
| > 	(let ((*foo* *foo*)
| > 	      (*bar* *bar*)
| > 	      ...)
| > 	  ;; *FOO* and *BAR* are now protected from SETQs in other
| > 	  ;;  threads, and vice versa.
| > 	  ...)
| 
| There are a lot of other reasons for doing this!  In particular you
| may want to protect the variable from assignments in the *same* thread
| (or the only thread in a single-threaded implementation).
+---------------

Hunh? But it *won't* protect the variable from assignments in
the same thread! E.g.:

    > (defvar *foo* 13)

    *FOO*
    > (defun set-foo (n) 
	(setq *foo* n))

    SET-FOO
    > (defun show-foo ()
	(format t "foo = ~a~%" *foo*))

    SHOW-FOO
    > (let ((*foo* *foo*))
	(show-foo)
	(set-foo 52)
	(show-foo))
    foo = 13
    foo = 52
    NIL
    > 

I guess I don't understand your point...


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607