Phil Hagelberg <p...
> So it seems like recently the only thing I use AOT for is producing
> -main functions that can be easily run from the command-line. I've
> found that an alternate to this is to use clojure.main -e, require the
> necessary namespace, and then call (apply -main *command-line-args*),
> but this is rather awkward. I wonder if it would be convenient to have
> clojure.main take another argument that would accept the name of a
> namespace to look for a -main function in.
> Thoughts? Would others use this?
I agree that this would be an excellent addition and would improve
usability. I use clojure.main -e "(use 'foo)(-main)" all the time as
well but it's probably pretty baffling to new users as to how they are
actually supposed to run their programs outside of an IDE.
Just putting code at the top-level is not suitable as it will be run
whenever the namespace is loaded -- which is not what you want when
compiling or generating documentation. Some languages do this like
Python's "if __name__ == '__main__': main(*sys.argv)"
boilerplate, but this is ugly and unnecessarily repetitive as they
almost always just call main() anyway.
Virtually every program larger than a trivial script is going to have a
main function of some sort, so I think languages should really take it
into account directly.
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to email@example.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
For more options, visit this group at