[racket] Order dependency in submodules

From: Laurent (laurent.orseau at gmail.com)
Date: Fri Jul 11 08:12:08 EDT 2014

Thanks for the explanation!

Laurent


On Thu, Jul 10, 2014 at 12:50 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> I think the ordering of submodules is unavoidable, but the
> documentation should make more clear that the order of `module*`
> declarations matters.
>
> Meanwhile, the documentation for `module+` needs to clarify that it
> puts the generated `module*` at the end of the enclosing module, even
> if there's only one `module+` form for a module name. It should also
> say that the order of the generated `module*`s for multiple
> `module+`-based modules corresponds to the order of the initial
> `module+` for each name (which turns out to be an explicit choice, as
> opposed to an accident of the implementation).
>
> At Tue, 1 Jul 2014 10:16:06 +0200, Laurent wrote:
> > Hi,
> >
> > I'm using `(module+ plot)` to avoid loading the `plot` library when
> > requiring the enclosing module only.
> >
> > But it seems that `module+` is dependent on the order of the modules,
> > somewhat contrarily to `module*`. For example, this works:
> > #lang racket
> >
> > (define x 3)
> >
> > (module+ foo
> >   (provide y)
> >   (define y x))
> >
> > (module+ test
> >   (require (submod ".." foo))
> >   y)
> >
> > But this does not:
> > #lang racket
> >
> > (define x 3)
> >
> > (module+ test) ; *** ADDED
> >
> > (module+ foo
> >   (provide y)
> >   (define y x))
> >
> > (module+ test
> >   (require (submod ".." foo))
> >   y)
> >
> > But this works:
> > #lang racket
> >
> > (define x 3)
> >
> > (module+ test)
> >
> > (module* foo #f ; *** CHANGED
> >   (provide y)
> >   (define y x))
> >
> > (module+ test
> >   (require (submod ".." foo))
> >   y)
> >
> > And this works too:
> > #lang racket
> >
> > (define x 3)
> >
> > (module+ foo) ; *** ADDED
> > (module+ test)
> >
> > (module+ foo ; ***
> >   (provide y)
> >   (define y x))
> >
> > (module+ test
> >   (require (submod ".." foo))
> >   y)
> >
> > I want to use `module+` over `module*` for its concatenation capability,
> > and adding a `(module+ foo)` at the top of my file is no big deal, but,
> > since the docs do not talk about some order dependency of submodules
> > (AFAICT) and only say that `module+` is equivalent to `module*` with #f
> and
> > concatenation, I was wondering if this was the intended behavior.
> >
> > Actually, `module*` also seems to be dependent of the order, as the
> > following does not work:
> > #lang racket
> >
> > (define x 3)
> >
> > (module* test #f
> >   (require (submod ".." foo))
> >   y)
> >
> > (module* foo #f
> >   (provide y)
> >   (define y x))
> >
> > From this I infer that the modules declared by `module+` are collected in
> > order of their first appearance and declared at the end of the module in
> > this same order, therefore after all `module*`. Is this correct?
> >
> > And is it easy enough to have order independence for both `module+` and
> > `module*`, and would it be a good idea in general?
> >
> > Laurent
> > ____________________
> >   Racket Users list:
> >   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140711/6c6c57ec/attachment.html>

Posted on the users mailing list.