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 defacto standard on clj files I've seen is to provide an application function commented out at the bottom of the file.
What might be nice is to have a check for 'included' or 'loaded' vs 'executed'. This can almost be done by looking at *command-line-args*, however not quite because the standard launcher does not include $0. So you have to use a non-standard launcher which includes $0 to achieve this: (when *command-line-args* (main *command-line-args*)) There is discussion about this previously: http://groups.google.com/group/clojure/browse_thread/thread/9ec09e7826992ea8/9e0085eb74061274 http://groups.google.com/group/clojure/browse_thread/thread/ca60d98fb4f7e71e/16b0ebb277daf5b9 Regards, Tim. On Mar 15, 12:55 pm, Keith Bennett <keithrbenn...@gmail.com> wrote: > 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 athttp://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 could > just list the contents of main() outside any function, and it would > work the same way. > > So which approach is better, and why? > > Thanks, > Keith --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---