This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: tie variable
- To: guile at sourceware dot cygnus dot com
- Subject: Re: tie variable
- From: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Date: 02 Apr 2000 13:11:40 -0400
- References: <m3ya7lx4i5.fsf@kei.cwru.edu>
Hello,
I wrote:
> 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)
(environment-set! lisp-environment 'user-full-name value)
-> (global-set! 'user-full-name value)
And using this at top level, will those variables defined in
the lisp-environment be referred/modified appropriately?
If this can be done, this works just like tie variables.
Thanks,
Keisuke Nishida