Brian Mastenbrook scripsit: > ==> #!r6rs > (library (locative) > (export get-value set-value!) > (import (rnrs base (6))) > > (define value #f) > (define value-set #f) > > (define get-value > (lambda () > (if value-set > value > (error #f "value not yet set")))) > > (define set-value! > (lambda (v) > (set! value v) > (set! value-set #t) > v))) > ==> #!r6rs > (library (foo) > (export a) > (import (rnrs base (6))) > (define a 1)) > ==> #!r6rs > (library (bar) > (export) > (import (rnrs base (6)) > (locative) > (foo)) > (set-value! (lambda () a))) > ==> #!r6rs > (import (rnrs base (6)) > (locative) > (foo) > (bar)) > ==> ((get-value)) > 1 > ==> #!r6rs > (library (foo) > (export a) > (import (rnrs base (6))) > (define a 2)) > ==> #!r6rs > (import (rnrs base (6)) > (locative) > (foo)) > ==> ((get-value)) > ??? ; BLANK 1: 1 or 2?
1, because bar imported the version of foo that was extant when it was loaded. (I speak of "loading" a library without loss of generality even if, as here, you type it into the REPL.) > ==> #!r6rs > (import (rnrs base (6)) > (locative) > (foo) > (bar)) > ==> ((get-value)) > ??? ; BLANK 2: 1 or 2? 1, for the same reason. > ==> #!r6rs > (library (bar) > (export) > (import (rnrs base (6)) > (foo)) > (define z ((get-value))) > ==> #!r6rs > (import (rnrs base (6)) > (locative) > (foo) > (bar)) > ==> z > ??? ; BLANK 3: 1 or 2? 2, because you have redefined bar. This threw away the old bar and loaded a new bar which imports the current (new) definition of foo. -- Work hard, John Cowan play hard, [email protected] die young, http://www.ccil.org/~cowan rot quickly. _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
