Hello Guilers! Andy Wingo writes: > 2004-12-22 Marius Vollmer > > * boot-9.scm (module-make-local-var!): When creating a new > variable, initialize it to the value of any imported variable with > the given name. This allows code like (define round round) to > work as expected. (See also: http://cvs.savannah.gnu.org/viewvc/guile/guile-core/ice-9/boot-9.scm?root=guile&r1=1.341&r2=1.342) Andy and I discussed this issue on IRC. It turns out that my recent changes in the module system (allowing for lazy duplicate binding checks) revert this change, for the reasons mentioned by Andy ("superfluous" overhead). However, in doing so it breaks `(define round round)' ("unbound variable"). Inverting the order of the calls to `scm_sym2var ()' and `scm_eval_car ()' in `scm_m_define ()' so that it first evaluates the value, and then creates the variable and assigns it the just-evaluated value fixes the problem. Alas, it breaks the following test in `syntax.test': (pass-if "binding is created before expression is evaluated" (= (eval '(begin (define foo (begin (set! foo 1) (+ foo 1))) foo) (interaction-environment)) 2)) This test case illustrates the fact that _internal_ defines are equivalent to `letrec' (Section 5.2.2); top-level defines should behave similarly for new variables (Section 5.2.1). For top-level defines as in `(define round round)', the rule is that `define' is equivalent to `set!' when the variable is already bound (Section 5.2.1). This justifies the change made by Marius to `module-make-local-var!' (above). Consequently: * `module-make-local-var!' cannot be changed in 1.8; * `module-make-local-var!' in HEAD must be reverted to its previous definition (attached patch). This is _very_ unfortunate performance-wise, as Andy noted, but I don't have any better idea ATM. :-( Thanks, Ludovic.