Of course, defining the function makes it easier to invoke your code if you
think it might have wider usefulness.
Joshua
On Sun, Mar 15, 2009 at 3:55 AM, Keith Bennett keithrbenn...@gmail.comwrote:
Is it a good idea or a bad idea to provide a main() function as the
program's entry point?
As
Hi Keith,
IMO it is slightly better to use a function as you described. The
benefit being that it makes it easier to test your helper functions
without running the main application. For instance if you comment out
(main) and load the file to the REPL or call a test function instead.
It seems the
Hello,
And one more added benefit is that if you (or something using your
namespace) uses IDEs that auto-load (or auto-compile) the clj files each
time they are saved (such as clojuredev does), it would be impractical to
have a namespace auto-execute itself. Because then, the auto-load
A couple of small corrections:
the :gen-class directive needs (:main true) to tell it you have a main
function:
(ns temp-converter
(:gen-class (:main true))
and the main function needs an argument declaration:
(defn -main [] (main))
Tom
On Mar 15, 2:05 am, Laurent PETIT
oops, sorry for the argument declaration.
Concerning the need to have (:main true), it's weird, because it worked for
me without it.
2009/3/15 Tom Faulhaber tomfaulha...@gmail.com
A couple of small corrections:
the :gen-class directive needs (:main true) to tell it you have a main
On Mar 15, 2009, at 4:42 PM, Tom Faulhaber wrote:
the :gen-class directive needs (:main true) to tell it you have a main
function:
(ns temp-converter
(:gen-class (:main true))
(:main true) is the default for the :gen-class directive.
Here's the relevant portion of (doc ns) (and
Is it a good idea or a bad idea to provide a main() function as the
program's entry point?
As an example, I have a program at http://is.gd/ndTV. If you look at
the bottom you'll see (unless and until I change it) the specification
of a main function, and then a call to it. I'm aware that I