Hello,

function -main is a regular function, so the following works :
"
$ echo "(ns test (:gen-class)) (defn -main [] (println 1))" > test.clj
$ java -cp clojure.jar clojure.main -i test.clj -e "(test/-main)"

1
"

HTH,

-- 
Laurent

2009/4/8 Mark Reid <mark.r...@gmail.com>

>
> Hi Laurent,
>
> Thanks for the feedback regarding namespaces. That's exactly the sort
> of thing I wasn't sure I was doing correctly.
>
> I currently don't use an IDE that automatically compiles files so
> wasn't aware of that problem. I prefer the solution that defines a
> main method. My only question now is, if I don't want to compile the
> test class, how do I call the main method from the command line?
>
> Regards,
>
> Mark.
> --
> http://mark.reid.name
>
> On Apr 7, 7:35 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
> > Hello Mark,
> >
> > That's interesting, keep us informed of your progress!
> >
> > Since you say you welcome any feedback, here are my remarks :
> >
> >  * namespace names: you could maybe use more qualified names, e.g.
> > qualifying them maybe with your own reversed namespace ( vec ->
> com.reid.vec
> > ). Indeed, one of the interests of namespaces is to avoid name clashes,
> and
> > it feels to me like creating namespaces of just one segment with such
> > generic names such as vec may not scale well, even for personal work ?
> >
> > * you have a file named test/test.clj . The corresponding namespace
> > declaration should then be (ns test.test ...) instead of (ns test ...).
> >
> >  * function calls in namespaces : your namespace 'test directly executes
> a
> > call. This would be problematic for people using IDEs that automatically
> > regularly auto-compile or auto-load files to give user error/warning
> > feedback.
> > One alternative solution could be to just guard the call against
> compilation
> > by checking the value of the *compile-files* global var :
> > (when-not *compile-files*
> >   (run-tests 'test.vec))
> > Another alternative could be to completely get rid of the immediate call
> to
> > run-tests and place it instead in a -main method, so that the ns can be
> used
> > as an independent executable file:
> >
> > (ns test
> >   (:gen-class)
> >   (:use test.vec)
> >   (:use clojure.contrib.test-is))
> >
> > (defn -main [] (run-tests 'test.vec))
> >
> > HTH,
> >
> > --
> > Laurent
> >
>

--~--~---------~--~----~------------~-------~--~----~
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