Modulinos: Difference between revisions

Content added Content deleted
Line 128: Line 128:
Clojure has a function -main which will run in only four cases.
Clojure has a function -main which will run in only four cases.


# clj is passed the flag -m &lt;class&gt; <lang sh>$ clj -m scriptedmain
# clj is passed the flag -m &lt;class&gt;. <lang sh>$ clj -m scriptedmain
Main: The meaning of life is 42
Main: The meaning of life is 42
$ clj -m test
$ clj -m test
Test: The meaning of life is 42</lang>
Test: The meaning of life is 42</lang>
# A shebang forces -m &lt;class&gt; <lang sh>$ ./scriptedmain.clj
# A shebang forces -m &lt;class&gt;. <lang sh>$ ./scriptedmain.clj
Main: The meaning of life is 42
Main: The meaning of life is 42
$ ./test.clj
$ ./test.clj
Line 140: Line 140:
$ java -cp ~/Library/Clojure/lib/clojure.jar:. test
$ java -cp ~/Library/Clojure/lib/clojure.jar:. test
Test: The meaning of life is 42</lang>
Test: The meaning of life is 42</lang>
# -main is explicitly called <lang sh>
# -main is explicitly called. <lang sh>
$ clj
$ clj
user=> (load-file "scriptedmain.clj")
user=> (load-file "scriptedmain.clj")