[racket] Order dependency in submodules

From: Laurent (laurent.orseau at gmail.com)
Date: Tue Jul 1 04:16:06 EDT 2014

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140701/53e16f4e/attachment.html>

Posted on the users mailing list.