Based on the input on the command line, I need to set some runtime constants that will use some downstream functions. The code in these functions can be executed in other threads, so I do not consider the combination of "declare var and use a binding macro." What are the pros and cons of using var (with alter-var-root) for this or using an atom? I.e
(declare *dry-run*) ; one of my constants (defn -main [& args] ; fetch command line option ;(cli args ...) (alter-var-root
against
(def *dry-run* (atom true)) (defn -main [& args] ; fetch command line option ;(cli args ...) (reset! *dry-run* ...) (do-stuff-in-thread-pool))
If there is another option, in addition to these two, which I should consider, I would like to know.
In addition, ideally, I would prefer not to provide an initial val for the atom, because I want to set the default values โโelsewhere (with cli), but I can live with it, especially if using the atom gives an advantage over the alternative ( s).
clojure
Don
source share