[plt-scheme] dynamic-require with no "provided" argument

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Thu Nov 13 08:08:06 EST 2008

Hi all,

I have a module called main.ss that runs an application from the  
command line:

     Trillian:~/my-application$ mzscheme main.ss
     Application started.

I'm trying to write another module, build.ss, to use as a make-file  
(using Noel's sake.plt package).

build.ss is going to do various things, including but not limited to  
compiling and running main.ss. I don't want any static compilation  
dependencies from build.ss to main.ss, so I thought I might try using  
dynamic-require for the running part (another option is to use the  
system procedure to run mzscheme in a separate process).

I tried writing this:

     (dynamic-require (build-path "main.ss") (void))

but nothing happened. I then tried refactoring main.ss and bundling  
the code into a "run-application" procedure:

     (let ([run-application (dynamic-require (build-path "main.ss")  

Doing this makes the application run twice. The docs say that dynamic- 
require "visits" and "instantiates" a module when a variable name is  
specified, but only "instantiates" the module if void is specified.  
I'm guessing that the instantiation part is what actually runs the  
code in the module, so both main.ss and build.ss must be calling run- 

Two questions then:

1. Is there a way of visiting and instantiating a module without  
requiring a particular variable? The obvious quick hack of removing  
the call to (run-application) above seems a bit daft.

2. Is this all dubious and wrong and should I be using (system  
"main.ss") instead?

Many thanks,

-- Dave

Posted on the users mailing list.