David Golden <david.golden@oceanfree.net> wrote:
+---------------
| Russell Wallace wrote:
| > Is there any way to just declare an ordinary variable at global scope
| > without making it dynamic?
|
| Yes and no. They're not in the standard directly.
|
| There is, however, a way of emulating lexically scoped globals - without
| stepping outside common lisp proper - with symbol-macros. Usually
| referred to as "deflexical" or "deflex" macros.
|
| e.g. Kent Pitman, 1998,
| Message-ID: <sfwbtsb6b0c.fsf@world.std.com>#1/1
| http://groups.google.com/group/comp.lang.lisp/msg/740caf30dd637ce8
|
| Rob Warnock, 2003,
| Message-ID: <NvednWDvaYM0GbKiXTWc-g@speakeasy.net>
| http://groups.google.com/group/comp.lang.lisp/msg/a76aac465c18a0a4?dmode=source
+---------------
And free code here:
http://rpw3.org/hacks/lisp/deflex.lisp
-Rob
p.s. Note to CMUCL users: CMUCL-19d and earlier had a bug in macro
expansion [routine MACROEXPAND-1, file ".../src/code/eval.lisp"] such
that in some cases [e.g., "INCF FOO", but not just "FOO" or "SETF FOO"]
references to symbol macros that had been shadowed by lexical variables
expanded to the symbol macro expansion instead of refering to the lexical
variable. This bug was fixed in the CVS as of Revision 1.43 2006-12-19.
CMUCL-19e and later versions contain that fix. If you are running
CMUCL-19c or -19d, I posted a patch here on 2006-12-18 in article
<URL:news:Y_Cdnbvi_4Ir4RvYnZ2dnUVZ_tunnZ2d@speakeasy.net>. Or you
can just snarf "eval.lisp" from the -19e source tarball.
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607