Thank you all for the ideas.<div><br></div><div>[]'s</div><div><br clear="all">Rodolfo Carvalho<br>
<br><br><div class="gmail_quote">On Thu, Jun 2, 2011 at 20:44, Neil Van Dyke <span dir="ltr"><<a href="mailto:neil@neilvandyke.org">neil@neilvandyke.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Rodolfo Carvalho wrote at 06/02/2011 05:42 PM:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I would like a have a file that when run standalone executes some code, and when "required" by another module just provides some definitions.<br>
<br>
</blockquote>
<br></div>
The following works on Linux. You might have to change the "/usr/bin" to be whatever directory your "racket" executable is in.<br>
<br>
<br>
#!/usr/bin/racket -ucm<br>
#lang racket/base<br>
<br>
(define foo 42)<br>
<br>
(define (bar x) (* x 2))<br>
<br>
(define (main)<br>
(display "Hello, world!\n"))<br>
<br>
(provide foo bar main)<br>
<br>
<br>
If "-ucm" is difficult to remember, the "m" has to be last, but one can swap the order of the "u" and the "c", for a mnemonic that no student will forget.<br>
<br>
Also, "-M" (uppercase) isn't yet used as a command line option, so that might be good shorthand to add for this kind of module/script. Perhaps "-M" could permit the procedure name after, since requiring multiple modules providing "main" would be a pain outweighing the convenience, IMHO. I think it would require a low-level change to the command-line parser (since"#!" wants to read only a single argument).<br>
<font color="#888888">
<br>
-- <br>
<a href="http://www.neilvandyke.org/" target="_blank">http://www.neilvandyke.org/</a><br>
<br>
</font></blockquote></div><br></div>