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


Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE> writes:

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

(I rename global-ref to lisp-variable-ref.)

Sorry.  I want to call an user-defined procedure lisp-variable-ref
whenever a variable is referred in Scheme programs and a procedure
lisp-variable-set! whenever a variable is set by using set!.

Since Emacs Lisp uses dynamic bindings, the object related to a symbol
may change during execution.  For some reasons, I decided to call a set
of procedures to handle this.  I used the following notation previously:

  (define user-full-name
    (make-procedure-with-setter
     (lambda () (lisp-variable-ref 'user-full-name))
     (lambda (val) (lisp-variable-set! 'user-full-name val))))

  (user-full-name)
  (set! (user-full-name) value)

But I want to do the same thing by the following notation:

  user-full-name
  (set! user-full-name value)

I'm wondering if I can do that by using the new top-level environment.

> 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?

For some reasons, I'm not doing that.

Thanks,
Keisuke Nishida

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