> (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
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
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.
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
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