On Fri, Apr 27, 2012 at 22:21 -0700, Sean Corfield wrote:
> On Fri, Apr 27, 2012 at 4:14 AM, Wolodja Wentland <babi...@gmail.com> wrote:
> > Could you elaborate on that please? I see that dynamic variables are used 
> > quite
> > often to give the user the ability to configure/change the behaviour of a
> > library. That approach is often coupled with a macro that changes the 
> > bindings
> > of dynamic variables.
> 
> A better approach is to provide an API where the "changes" can be
> passed in as function arguments. Dynamic variables smack of imperative
> programming to me...
> 
> When I asked Clojure/core to review c.j.jdbc in the context of a
> potential future 1.0.0 release, the use of dynamic variables was one
> of the issues that came up. The current variables will probably remain
> for backward compatibility but a new API or an extension to the
> current API will be added that provides a more functional style
> without requiring dynamic variables - and the existing code rewritten
> in terms of that new API.
> 
> Hope that clarifies?

It certainly does, but I am none the wiser. I always had the feeling/impression
that dynamic variables are something to be avoided, but I see them frequently
in Clojure code I read and therefore have the impression that they are "the
right thing to do"™ in a couple of instances. I am definitely not trying to
argue that they are, but I find it hard to develop a better style if all the
libraries that I come across use dynamic variables.

How would you, for example, implement the logging example I quoted above? What
about handling global configuration (config files, CLI options, ..) ?

Thanks a lot for your time and for helping me understanding this a bit better.
-- 
Wolodja <babi...@gmail.com>

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC

Attachment: signature.asc
Description: Digital signature

Reply via email to