Re: setup and propagation of config-params

2011-03-11 Thread faenvie
> (set-opt :development) ; this is what you want > ... > (get-opt :show-sql) ; need this flag hi armando, this is more of an OO style but as there is no def- , the state is still accessible from the outside. also the api is kinda asymetric. as described in 'the joy of clojure 7.2 - sharing closu

Re: setup and propagation of config-params

2011-03-10 Thread Armando Blancas
Dynamic binding is more useful when your function expect the *var* to change during the program. And sometimes you can't pass arguments through, like in (run-tests). How about a simple API with this usage: (set-opt :development) ; this is what you want ... (get-opt :show-sql) ; need this flag Thi

Re: setup and propagation of config-params

2011-03-10 Thread faenvie
thanks ken for the answer. more(?) functional using closures: (defn get-config [environment] (let [env (condp = environment :development { :whoami "development"} :test { :whoami "test"} :production { :whoami "production"} (throw (IllegalArgumentException.

Re: setup and propagation of config-params

2011-03-10 Thread Ken Wesson
On Thu, Mar 10, 2011 at 9:51 AM, faenvie wrote: > references to *opts* are scattered all over my clojure-code > so that many of the functions are impure. this seems like > a smell to me and there are probably cleaner ways to propagate > config-params (keep functions pure) ... what are they ? Ther

setup and propagation of config-params

2011-03-10 Thread faenvie
hi clojure-users, i have a question regarding the setup and propagation of config-params. to configure a clojure-based web-app, i use a global var *opts* that is setup like this: (defn get-opts [environment] (condp = environment :development { :webapp-context "/myw