guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set-current-module broken in current Guile CVS version (anyone?)


From: Dirk Herrmann
Subject: Re: set-current-module broken in current Guile CVS version (anyone?)
Date: Wed, 7 Feb 2001 19:37:04 +0100 (MET)

On 7 Feb 2001, Marius Vollmer wrote:

> Dirk Herrmann <address@hidden> writes:
> 
> > The right fix is, to make define and define-public to behave alike, namely
> > to place their definitions in the current-module.
> 
> Are you sure?  [...]

Not any more :-)  Your suggestion to fix 'begin' is the right thing.  And,
not only for the module system and eval, but just to comply with R5RS.

> [...]  I would expect code liek this to still break
> 
>   (define-module (guile-user))
>   (begin 
>     (define-module (foo))
>     (define bar 12)
>     (define baz (lambda () baz)))
> 
> because the `lambda' closes over the wrong top-level environment,
> namely guile-user.

You are right.  My fix only makes sure that the _binding_ is created in
the right place.  With the broken 'begin' this can lead to the situation
that a binding for a function is created in a different module than the
top level environment of the closure.  With your suggested fix, it is
guaranteed that a function binding created by "define" in a top level
environment will close over that same top level environment.  Except,
certainly, if you try to explicitly avoid it like with

  (define-module (foo))
  (define bar (eval '(lambda () ...) <module baz>))

where bar is created in (foo), but the function closes over (baz).

Best regards,
Dirk Herrmann




reply via email to

[Prev in Thread] Current Thread [Next in Thread]