[racket-dev] submodules

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Thu Mar 8 15:41:38 EST 2012

This sounds great! I haven't tried it out yet, but here are some
preliminary comments.

On 2012-03-07 10:14:35 -0700, Matthew Flatt wrote:
> Submodules declared with `module' are declared locally while expanding
> a module body, which means that the submodules can be `require'd
> afterward by the enclosing module. This ordering means, however, that
> the submodule cannot `require' the enclosing module.
> [...]
> The `module*' form is like `module', but it can be used only for
> submodules, and it defers the submodule's expansion until after the
> enclosing module is otherwise expanded. As a result, a submodule using
> `module*' can `require' its enclosing module, while the enclosing
> module cannot require the submodule.

It seems to me that `module*` maybe actually be the common case for
submodules because most of the time I would expect that you want to use
the bindings of the enclosing module. This seems true for unit tests,
driver modules, documentation (requiring for-template), and so on.

Would it make sense to swap the `module` and `module*` forms?


Another aspect of the syntax that I foresee being annoying is that each
module nesting adds an additional indentation level. On the other hand, I
don't see any good alternative for this. I only bring this up because
this was problematic enough in the past to invent the #lang shorthand.

Maybe a pattern that could avoid this is to have something like

#lang racket/main
  #:main "driver.rkt"
  #:tests "tests.rkt"

which would bring in the given modules (in the filesystem) as
submodules.  That way you could define submodules separately  but still
package them together in order to follow any protocols for documentation
or unit testing that come about with submodules. Is that implementable
with submodules?


Posted on the dev mailing list.