On Fri, Jan 2, 2009 at 4:20 PM, Timothy Pratley
<timothyprat...@gmail.com> wrote:
>
> I suspect that *command-line-arguments* would have "myapp.clj" as the
> 0th element in the
> clj myapp.clj
> Can't test right now though sorry.

Good idea! Unfortunately it seems that *command-line-args* is nil
regardless of whether I load the code in a REPL or run it as a script.
It doesn't include the name of the script, just arguments that follow
it.

> On Jan 3, 3:34 am, "Mark Volkmann" <r.mark.volkm...@gmail.com> wrote:
>> I have a file of Clojure code that I'd like to experiment with in the
>> REPL. I use (load file-path) to do that and then I can try out the
>> functions it defines. At the bottom of the file it calls the functions
>> required to run my application. Is there a way I can write the code so
>> it only runs my application when I run it outside the REPL?
>>
>> For example, this should run the application:
>>
>> clj myapp.clj
>>
>> and this should not:
>>
>> clj
>> user=> (load-file "myapp.clj")
>>
>> Ruby has something like this. You surround the code that runs the app like 
>> this:
>>
>> if $PROGRAM_NAME == __FILE__
>>   # code to run application goes here
>> end

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to