<div dir="ltr"><div><div><div><div>Hi,<br><br></div><div>I'm using `(module+ plot)` to avoid loading the `plot` library when requiring the enclosing module only.<br></div><div><br></div>But it seems that `module+` is dependent on the order of the modules, somewhat contrarily to `module*`. For example, this works:<br>
#lang racket<br><br>(define x 3)<br><br>(module+ foo<br> (provide y)<br> (define y x))<br><br>(module+ test<br> (require (submod ".." foo))<br> y)<br><br></div>But this does not:<br>#lang racket<br><br>(define x 3)<br>
<br>(module+ test) ; *** ADDED<br><br>(module+ foo<br> (provide y)<br> (define y x))<br><br>(module+ test<br> (require (submod ".." foo))<br> y)<br><br></div><div>But this works:<br>#lang racket<br><br>(define x 3)<br>
<br>(module+ test)<br><br>(module* foo #f ; *** CHANGED<br> (provide y)<br> (define y x))<br><br>(module+ test<br> (require (submod ".." foo))<br> y)<br></div><div><br></div>And this works too:<br>#lang racket<br>
<br>(define x 3)<br><br>(module+ foo) ; *** ADDED<br>(module+ test)<br><br>(module+ foo ; ***<br> (provide y)<br> (define y x))<br><br>(module+ test<br> (require (submod ".." foo))<br> y)<br><br></div><div>
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.<br>
<br></div><div>Actually, `module*` also seems to be dependent of the order, as the following does not work:<br>#lang racket<br><br>(define x 3)<br><br>(module* test #f<br> (require (submod ".." foo))<br> y)<br>
<br>(module* foo #f<br> (provide y)<br> (define y x))<br><br></div><div>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?<br>
<br></div><div>And is it easy enough to have order independence for both `module+` and `module*`, and would it be a good idea in general?<br></div><div><br></div><div></div><div>Laurent<br></div><div><br><br></div></div>