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: tie variable


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> > I have a question of how to make a special variable in Scheme
> > that is like a tie variable in Perl.  Is there any way to call
> > a certain function whenever a variable is referred or modified?
> 
> >   (global-ref user-full-name)
> >   (global-set! user-full-name value)
> > 
> > But this is rather tedious.  I'd like to write:
> > 
> >   user-full-name
> >   (set! user-full-name value)
> 
> Could I do this by using the new top-level environment scheme?
> 
>   (define lisp-environment (make-lisp-environment))
> 
>   (environment-ref lisp-environment 'user-full-name)
>     -> (global-ref 'user-full-name)

Excuse me but what does "-> (global-ref ...)" mean?

environment-ref looks up a variable binding for `user-full-name' in
`lisp-environment' and returns a value.  If this value is
a closure and you invoke the closure, it will look up bindings
in the environment in which it was defined.


Also I don't understand why you want to have two separate variables
in the lisp and scheme environment.  Don't you translate
lisp to scheme code?


Jost

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