On Tue, 16 Feb 2010 11:13:28 -0800 (PST)
Daniel Werner <daniel.d.wer...@googlemail.com> wrote:

> On Feb 16, 2:12 am, Mike Meyer <mwm-keyword-googlegroups.
> 620...@mired.org> wrote:
> > Wouldn't be hard to do, either. Just bind *script-name* (or some such)
> > to the path in script-opt, and let the client decide if it's the same
> > as *file*.
> It would indeed be helpful if clojure.main bound a Var to the name of
> the .clj file being run, sort of like argv[0] in C. Like Michał
> suggested, there's the gen-class solution, but I personally tend avoid
> AOT-compiling Clojure code, which rules out gen-class.

I was surprised that *command-line-args* didn't include the script
name, which would have solved my problem. Of course, my usage is a
special case of the more general Unix trick of having programs vary
their behavior based on the name they were invoked with. And I just
realized another need for wanting the program name: how do I report
the program name in error messages? That's probably what argv[0] is
used for more than anything else.

Maybe the concept "name the program was invoked with" doesn't make
sense in a Java environment, what with having to have shell wrappers
around AOT code before it can be run anyway. Since clojure code can be
run as script, it might make sense there - if people distribute
applications a scripts instead of AOT code.

   <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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