Not close enough.
On Jun 2, 2011, at 6:51 PM, Robby Findler wrote: > You can get close if you use 'racket' to run the file; define a main > function that has the code that should only run in standalone and then > use the -m flag on the commandline. > > Robby > > On Thu, Jun 2, 2011 at 4:45 PM, Matthias Felleisen <[email protected]> > wrote: >> >> Not available yet, but thanks for asking: I requested this feature a month >> ago on our 'dev' list. >> >> >> >> >> On Jun 2, 2011, at 5:42 PM, Rodolfo Carvalho wrote: >> >>> Sorry if I didn't find it somewhere obvious, but I don't know how to do the >>> following. >>> >>> I would like a have a file that when run standalone executes some code, and >>> when "required" by another module just provides some definitions. >>> >>> Example: >>> >>> ;------------------------------------------------------- >>> ; my-lib.rkt >>> (provide make-milk-shake) >>> >>> (define (make-milk-shake flavor) >>> ...) >>> >>> ; run this only when run standalone >>> (magic-thing >>> (make-milk-shake 'banana) >>> >>> >>> ;------------------------------------------------------- >>> ; some-other.rkt >>> (require "my-lib.rkt") >>> >>> (make-milk-shake 'strawberry) >>> ; only make 1 milk shake of strawberry... >>> >>> >>> >>> That is, I am searching for an equivalent idiom for what in Python I'd >>> write: >>> >>> if __name__ == "__main__": >>> do_things() >>> >>> >>> >>> >>> []'s >>> >>> Rodolfo Carvalho >>> _________________________________________________ >>> For list-related administrative tasks: >>> http://lists.racket-lang.org/listinfo/users >> >> >> _________________________________________________ >> For list-related administrative tasks: >> http://lists.racket-lang.org/listinfo/users >> _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

