Module system

Jim Blandy (jimb@red-bean.com)
Mon, 25 Aug 1997 17:00:25 -0500

>I have been told that people are in the process of rethinking the
>guile module system, but that I should use it anyway.

Yeah.

>- What instances of define and define-public are affected by a
>define-module? From reading some old documentation, I had the
>impression that "define-module" applied to all the defines it
>contained, that is, you'd do:
>(define-module my-module
> (define a-variable 42))
>However, this is not consistent with current syntax. Why the change?
>The previous seems more consistent... And how do modules work now?

I don't know that define-module ever worked the old way. Under the
current system, a define-module form affects all definitions from its
appearance to the end of the file, or the next define-module form.

>- How would one lookup, say, the variable named "X" in the module
>named "Y"? For example:
>(define poe-pure-funcq (lookup #/ice-9/poe pure-funcq))

(define poe-pure-funcq
(module-ref (resolve-interface '(ice-9 poe)) 'pure-funcq))

There may be a more graceful way to do this.

>- How would one map the variable named "X" in the module named "Y"
>onto the variable named "Z"? (Allowing modifications to Z to also be
>modifications to X)

I don't know of a way to do this, although one might exist.

>- Is there a facility for renamed imports? (it's actually feasible to
>write one, given the ability to do the above)

Not that I know of, but as you say, it could be done.

>- In what module will the following create a new binding?
>(define new-func
> (lambda (name value)
> (eval `(define ,name ,value))))
>In the module new-func is called from, or the module new-func is
>defined in, or the root module?

The "current module", which is whatever one the "guile>" prompt is
talking to. Yes, this is a crock.