Good to know about the -m switch.<div><br></div><div>Is there a similar trick to use with DrRacket?</div><div><br></div><div>For now I have one module from where I want to demonstrate some functionality running it from DrRacket (with out using the Interactions window).</div>
<div><br></div><div>And I would use this same module as a "library" from another one.</div><div><br></div><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 19:51, Robby Findler <span dir="ltr"><<a href="mailto:robby@eecs.northwestern.edu" target="_blank">robby@eecs.northwestern.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You can get close if you use 'racket' to run the file; define a main<br>
function that has the code that should only run in standalone and then<br>
use the -m flag on the commandline.<br>
<font color="#888888"><br>
Robby<br>
</font><div><div></div><div><br>
On Thu, Jun 2, 2011 at 4:45 PM, Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>> wrote:<br>
><br>
> Not available yet, but thanks for asking: I requested this feature a month ago on our 'dev' list.<br>
><br>
><br>
><br>
><br>
> On Jun 2, 2011, at 5:42 PM, Rodolfo Carvalho wrote:<br>
><br>
>> Sorry if I didn't find it somewhere obvious, but I don't know how to do the following.<br>
>><br>
>> 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>
>> Example:<br>
>><br>
>> ;-------------------------------------------------------<br>
>> ; my-lib.rkt<br>
>> (provide make-milk-shake)<br>
>><br>
>> (define (make-milk-shake flavor)<br>
>> ...)<br>
>><br>
>> ; run this only when run standalone<br>
>> (magic-thing<br>
>> (make-milk-shake 'banana)<br>
>><br>
>><br>
>> ;-------------------------------------------------------<br>
>> ; some-other.rkt<br>
>> (require "my-lib.rkt")<br>
>><br>
>> (make-milk-shake 'strawberry)<br>
>> ; only make 1 milk shake of strawberry...<br>
>><br>
>><br>
>><br>
>> That is, I am searching for an equivalent idiom for what in Python I'd write:<br>
>><br>
>> if __name__ == "__main__":<br>
>> do_things()<br>
>><br>
>><br>
>><br>
>><br>
>> []'s<br>
>><br>
>> Rodolfo Carvalho<br>
>> _________________________________________________<br>
>> For list-related administrative tasks:<br>
>> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
><br>
><br>
> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
><br>
</div></div></blockquote></div><br></div>