Subject: Re: change a global var from a function?
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 26 Aug 2003 01:39:15 -0500
Newsgroups: comp.lang.lisp
Message-ID: <MfOdnfmX3t8OndaiXTWc-g@speakeasy.net>
Hmmm... I just wrote:
+---------------
| Joe Marshall  <jrm@ccs.neu.edu> wrote:
| +---------------
| | There are 3 ways I can think of:
| |     1.  The value of a global variable is stored in the symbol value
| |         cell.  Pass the quoted name of the symbol:
| +---------------
| 
|       4. Implement the global variable as a object within which the
|          value can be "boxed", rather than as the naked value itself.
|          Then you can change a slot in the box...
+---------------

I should probably point out that Joe's method #1 is mostly equivalent
to my #4, but using SYMBOL as the "box" type and SYMBOL-VALUE as the
value slot accessor. The main reason for choosing #4 over #1 is that
#4 doesn't require polluting the symbol space of the package you're in.
That is, for every such distinct "box" you want to pass around, #1
requires that you come up with a non-conflicting symbol name; #4 doesn't.

[Also, a symbol is a *big* object compared to a one-slot structure;
even bigger compared to implementing the "box" type as a CONS (that
"exercise for the reader" left undone in my previous)...]


-Rob

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