Subject: Re: Global lexical variables?
From: (Rob Warnock)
Date: Thu, 30 Oct 2008 22:41:41 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
David Golden  <> 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: <>#1/1
| Rob Warnock, 2003,
| Message-ID: <>

And free code here:


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
<>. Or you
can just snarf "eval.lisp" from the -19e source tarball.

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607