[R6RS] modules?

Matthew Flatt mflatt
Thu May 20 17:19:56 EDT 2004


I think you're saying that you want Chez's `module' in addition to a
file-level notion of module...

At Thu, 20 May 2004 16:21:10 -0400, Marc Feeley wrote:
> 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.

If you have local modules, then you can organize your script into
modules within the single, script-level (i.e., file-level) module.

> 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.

Part of my definition of a top-level "module" is that it's a
compilation unit, so mutual references don't work.

But mutual references are ok among internal modules.

> 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"
>   ...
> )

What if you need to use modules in "foo/bar/mymods.scm" and
"baz/yourmods.scm", and they both have a module named `b'? Now you need
a way to distinguish the different `b's.

As you elaborate `use' to account for these mappings, it will look more
and more like `require'.

And some of those mappings should be local to the file, in case the
file is incorporated into an even larger program. If someone `use's the
above file to get `a', you may not want them to get the `b' mappings.
In other words, `use' needs to have something like a file-level scope.

So you have files that refer to other files, and there's some notion of
file-level scope. I claim that your file are "modules" in the MzScheme

(Of course, as I've said before, I'm open to using different terms for
the top-level, file-level notion that I usually call "module".)


More information about the R6RS mailing list