Re: Global lexical variables?
- From: rpw3@xxxxxxxx (Rob Warnock)
- Date: Thu, 30 Oct 2008 22:41:41 -0500
David Golden <david.golden@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>#1/1
| http://groups.google.com/group/comp.lang.lisp/msg/740caf30dd637ce8
|
| Rob Warnock, 2003,
| Message-ID: <NvednWDvaYM0GbKiXTWc-g@xxxxxxxxxxxxx>
| 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@xxxxxxxxxxxxx>. Or you
can just snarf "eval.lisp" from the -19e source tarball.
-----
Rob Warnock <rpw3@xxxxxxxx>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
.
- References:
- Global lexical variables?
- From: Russell Wallace
- Re: Global lexical variables?
- From: David Golden
- Global lexical variables?
- Prev by Date: Re: Lexical closures - difference between Common Lisp and Ruby
- Next by Date: Re: Is it a bad sign...
- Previous by thread: Re: Global lexical variables?
- Next by thread: Re: Global lexical variables?
- Index(es):