This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: forcing a getter for variable accesses


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]