This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
variable binding
- To: guile at sourceware dot cygnus dot com
- Subject: variable binding
- From: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Date: 24 Aug 2000 00:59:13 -0400
Hello,
I'm not sure if this is a bug or a feature, but Guile does the following:
% guile -q
guile> (define (foo) (+ 1 2))
guile> (foo)
3
guile> (define + -)
guile> (foo)
3
But,
% guile -q
guile> (define (foo) (+ 1 2))
guile> (define + -)
guile> (foo)
-1
I guess Guile determines the binding of `+' when `foo' is first called,
not when it is defined. Also, it seems Guile overwrites the binding
only at the first time `define' is called in a module:
% guile -q
guile> (define + +)
guile> (define (foo) (+ 1 2))
guile> (foo)
3
guile> (define + -)
guile> (foo)
-1
I guess this is because `define' creates a new binding in a module when
first called, then it works same as `set!' as written in R5RS. However,
when a variable is imported from another module, a new binding is not
created, and Guile uses the location created in the other module.
My question is what is the expected behavior. How should `define' work
with modules, and when should bindings be resolved?
Thanks in advance.
Keisuke Nishida