[plt-scheme] Modules and extensions (yes, again)

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Apr 19 10:56:18 EDT 2003

At Fri, 18 Apr 2003 18:31:25 -0400, "Pedro Pinto" wrote:
> I posted here last week with question on modules and extensions.
> Basically my question was how to use require to load a module which was
> created by an extension with a name unknown until runtime. Matthew was
> kind enough to point me to the `current-module-name-resolver' parameter.
> [...]
> The problem with this is that:
> (require (library '()))
> ends up invoking my-resolver (and myCreateModule) twice (although it
> otherwise works as intended).
> What I am missing here?

The module-name resolver has two reposnsibilities:

  * transforming a `require' specification into a symbolic module name;

  * loading modules on demand.

"On demand" doesn't necessarily mean that every transformation implies
a load. For example, the compilation of `(require (library '()))'
resolves the name once while compiling the require declaration, and
them again to execute it. In short, the resolver needs some sort of
table to know whether it has already loaded a particular module.

The table of loaded modules should be namespace-specific. Note that
`namespace-attach-module' can introduce a module declaration into a
namespace without resolving any require spec; in that case, the
module-name resolver gets a "notification" call (indicated by a #f
spec), so that it can keep its table in sync.


Posted on the users mailing list.