<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm seeing an inconsistency in the behavior of submodules that looks like a bug in DrRacket (as opposed to Racket).<div><br></div><div>First, though, it looks like running a module in DrRacket runs *both* the main and test submodules, if they both exist. I don't think this behavior is documented; I see this text:</div><div><br></div><div>"When a module is provided as a program name to the <span class="stt">racket</span>
executable or run directly within DrRacket, if the module has a
<a name="(idx._(gentag._1._(lib._scribblings/guide/guide..scrbl)))"></a><span class="RktSym">main</span> submodule, the <span class="RktSym">main</span> submodule is run
after its enclosing module."</div><div><br></div><div>… but no similar mention of 'test'. So I'm guessing that's just a doc bug?</div><div><br></div><div>The bigger issue, though, arises when I have a file containing both 'test' and 'main' submodules. It appears to me that I can't require the 'main' module externally when the modules are stored in separate files, but that I can when e.g. using #lang racket/load.</div><div><br></div><div>So, this program:</div><div><br></div><div>#lang racket/load</div><div><br></div><div>(module foo racket</div><div>(define (g) (printf "abc\n"))</div><div>(define (h) (printf "def\n"))</div><div><br></div><div>(module+ test</div><div>&nbsp; (g))</div><div><br></div><div>(module+ main</div><div>&nbsp; (h))</div><div>)</div><div><br></div><div>(module bar racket</div><div>&nbsp; (require (submod 'foo main)))</div><div><br></div><div>(require 'bar)</div><div><br></div><div>… produces output "def", as I'd expect, but splitting it into two files:</div><div><br></div><div>foo.rkt:</div><div><br></div><div>#lang racket</div><div><br></div><div>(define (g) (printf "abc\n"))</div><div>(define (h) (printf "def\n"))</div><div><br></div><div>(module+ test</div><div>&nbsp; (g))</div><div><br></div><div>(module+ main</div><div>&nbsp; (h))</div><div><br></div><div><br></div><div>bar.rkt:</div><div><br></div><div>#lang racket</div><div><br></div><div>(require (submod "foo.rkt" main))</div><div><br></div><div><br></div><div><br></div><div>… and running "bar.rkt" &nbsp;*in DrRacket* produces this message:</div><div><br></div><div>require: unknown module: (submod "/private/tmp/foo.rkt" main)</div><div><br></div><div><br></div><div>Running it from the command line, though, does what I'd expect:</div><div><br></div><div><div>pcp069222pcs:/tmp clements$ racket ./bar.rkt</div><div>def</div></div><div><br></div><div><br></div><div><br></div><div>So it looks like DrRacket's not doing quite the right thing here.</div><div><br></div><div>Apologies if this has been fixed since&nbsp;&nbsp;5.3.0.2--2012-04-20(873c1bc/g) [3m].</div><div><br></div><div>John</div><div><br></div></body></html>