This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: variable binding
[
(define (foo) +)
(foo)
(define + -)
(foo)
doesn't work correctly in the current module system]
Marius Vollmer <mvo@zagadka.ping.de> writes:
> Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:
>
> > This is not defined by R5RS. I think the safest and most useful
> > behaviour is if `define' always "begins" with creating a new binding
> > in the local module, and then behaves as specified in R5RS, i.e., as
> > `set!'.
>
> However, when `define' creates the new binding in the local module,
> all previously memoized bindings should be invalidated and forced to
> be re-looked-up. Jim's environment proposal has hooks for this, I
> believe.
Jo. The problem is actually the design of the evaluator, not the
module system -- or better: It's a problem with Aubrey's memoizer.
The memoizer has captured a binding which is no longer valid after it
has been shadowed by `(define + -)'.
R5RS is clear how a top-level define should behave: It must create
a new binding if there is currently no binding in the current environment.
This means that (define + -) must shadow the imported binding (+ . +proc).
Because Aubrey's evaluator replaces every symbol by a pointer to the
location (not a pointer to a pointer to a location, which would be
correct!) the code must examine every memoized expession and unmemoize
the pointer back into the original symbol.
That's why the new module system really needs a new evaluator. [among
other things ...] :)
Btw: I tested this with SCM 2b2 (or something) yesterday and after I
typed the second (foo) I received a core dump. :))
Jost