This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: forcing a getter for variable accesses
- To: Greg Badros <gjb@cs.washington.edu>
- Subject: Re: forcing a getter for variable accesses
- From: Michael Livshin <mike@olan.com>
- Date: 08 Sep 1999 22:02:15 +0200
- Cc: guile@sourceware.cygnus.com
- Organization: who? me?
- References: <qrrn1uxb7mh.fsf@elwha.cs.washington.edu>
- Reply-to: Michael Livshin <mike@olan.com>
Greg Badros <gjb@cs.washington.edu> writes:
> Is there any way currently to force access to a variable via a getter
> procedure? E.g., in Scwm we have user-configurable variables such as
>
> *desk-width*
>
> that we want people to access by using (optget *desk-width*) instead of
> just *desk-width*. In this case, the variable has a getter function:
> (car (desk-size))
>
> I'm looking for thoughts about how to force using the getter function
> w/o requiring all accesses to be inside the `optget' macro. I think
> this is generally useful for guile, so if it's not already possible,
> it'd be nice if we could make it possible.
don't export a variable at all, and instead export a function:
(*desk-width*) - gets the value
(*desk-width* new-value) - sets the value
this approach is used alot, for instance, in MzScheme & Chez. it's
nice because it exports exactly what is needed - a way to access and
modify some value. no more, no less.
> The only thing I can think of is trying to use a reader extension and
> rename all of our user variables to use hashes instead, e.g.,
> #desk-width#.
_ouch_.
> Thanks,
> Greg
--mike