I'm seeing an inconsistency in the behavior of submodules that looks like a bug 
in DrRacket (as opposed to Racket).

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:

"When a module is provided as a program name to the racket executable or run 
directly within DrRacket, if the module has a main submodule, the main 
submodule is run after its enclosing module."

… but no similar mention of 'test'. So I'm guessing that's just a doc bug?

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.

So, this program:

#lang racket/load

(module foo racket
(define (g) (printf "abc\n"))
(define (h) (printf "def\n"))

(module+ test
  (g))

(module+ main
  (h))
)

(module bar racket
  (require (submod 'foo main)))

(require 'bar)

… produces output "def", as I'd expect, but splitting it into two files:

foo.rkt:

#lang racket

(define (g) (printf "abc\n"))
(define (h) (printf "def\n"))

(module+ test
  (g))

(module+ main
  (h))


bar.rkt:

#lang racket

(require (submod "foo.rkt" main))



… and running "bar.rkt"  *in DrRacket* produces this message:

require: unknown module: (submod "/private/tmp/foo.rkt" main)


Running it from the command line, though, does what I'd expect:

pcp069222pcs:/tmp clements$ racket ./bar.rkt
def



So it looks like DrRacket's not doing quite the right thing here.

Apologies if this has been fixed since  5.3.0.2--2012-04-20(873c1bc/g) [3m].

John

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Reply via email to