Subject: Re: Help understanding closures
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 13 Mar 2003 16:10:23 -0600
Newsgroups: comp.lang.lisp
Message-ID: <tBidnRgrTrZSnOyjXTWc-w@speakeasy.net>
Johan Ur Riise  <r@rsc.no> wrote:
+---------------
| > > jtdubs@eos.ncsu.edu (Justin Dubs) writes:
| > > > (let ((x 1))
| > > >   (eval '(print x)))
| > Peter Seibel <peter@javamonkey.com> wrote
| > >     (declare (special x))
| > >     (eval '(print x)))
| jtdubs@eos.ncsu.edu (Justin Dubs) writes:
| > This isn't really working.  By declaring x to be special, you have
| > transformed it from a lexical variable to a dynamic variable, thus
| > giving it global scope.  The entire reason that I used a let-construct
| > in my example was to give x local scope.  Atleast, that's my
| > understanding of "special" from CLHS 3.3.
| 
| Try this:
| (let ((x 1))
|     (eval `(print ,x)))
+---------------

Uh... That may "work" when X contains a number (like 1) or some other
self-evaluating object (e.g., vectors, strings), but not for conses
or symbols:

	(let ((x 'y))
	  (eval `(print ,x)))
	==> #<ERROR: Variable Y is unbound>


-Rob

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