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]

tie variable


Hello,

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?

One design issue of Guile Emacs is how to share the value of
customizable variables between Scheme and Lisp.  Whenever people
changed the value of variables in one language environment,
it had to affect the other environment.

Since I am going to not change the Lisp interpreter, I decided
to include a little trick in Scheme.  That is, a Scheme program
has to import a Lisp variable as a global variable like this:

  (define user-full-name (global-variable 'user-full-name))

Now, the value of user-full-name has to be always the same as
that of Lisp.  Also, changing the value of user-full-name has to
also change the value of Lisp's one.  For now I use the following
expressions for this purpose:

  (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)

Can I do this with connections to the value of the Lisp variable?

Thanks,
Keisuke Nishida

BTW, why not to write (global-ref 'user-full-name) whenever
it is necessary?  Because using the above import function, I could
call Lisp functions like (insert user-full-name), since the value
of global-variable is converted into Lisp data internally when I
use a Lisp function.  The problem is when I use a Scheme function.
Any better idea?

BTW2, sorry about my poor English.  I apologize if people have
had bad feelings with my writings.

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