[R6RS] modules?

Marc Feeley feeley
Thu May 20 16:21:19 EDT 2004

> At Sun, 02 May 2004 17:49:54 +0200, Michael Sperber wrote:
> > A while ago, I commented on "interfaces as nameable entitities" and
> > "more than one module per file."  Do you have any take on that?
> With multiple modules in one file, you need a way to refer to each
> particular module within a file. But filesystems already do a perfectly
> good job of handling hierarchy, so I favor multiple files within a
> directory, instead of multiple modules within a file.
> It's not a big issue to me. For MzScheme, we originally imposed the
> one-module-per-file constraint with the expectation that we'd try
> multiple modules later. But it's never seemed worth the trouble, and
> it's a rare request. (In contrast, putting helper functions for macros
> in the same module as the macro---as supported by Chez's `meta'---is a
> popular request.)

This touches an issue I raised earlier about scripts, i.e. how do you
write modular scripts.  If each module is required to be in its own
file, then a modular script is a set of files.  This bothers me
because you then have to think about how this set of files will be
distributed and installed.  I would like to have a module system where
you can have all the modules in a single file, i.e. the single script
file is is a sense "packaging" all the modules in a single place.

It seems to me that modules should only be named with identifiers and
be put in the lexical environment, with a kind of implicit letrec at
the toplevel.  So if a file contains:

(module a ...)
(module b ...)

Then each module could be referred from the other using these
identifiers, for example

(module a b ; module a uses the language b

Moreover, I think filenames and module identifiers should be decoupled.
Otherwise the location of a module in the filesystem becomes important.
I prefer having a separate declaration that indicates where modules
can be found, for example:

(use "foo/bar/mymods.scm")

(module a b ; module a uses the language b from file "foo/bar/mymods.scm"

The "use" form would add the modules in the given files to the lexical
environment.  Depending on how modules are instantiated (still not
clear to me), the "use" form could simply be "include".


More information about the R6RS mailing list