On Sat, Nov 14, 2009 at 14:55, Albert Cardona <[email protected]> wrote:
> On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye <[email protected]> wrote:
>> Why is there an easy way to def a private function (defn-), but no
>> similarly easy way to def an arbitrary var as private?
>
>
> The way I see it, def- would encourage gratuitous variable declaration
> imperative style.

Not necessarily.

I find myself quite often writing code like this:

(defn some-general-fn [a b c d] ...)

(def some-concrete-application-of-fn-above  (partial some-general-fn 42))

Having def- would be cool for such constructs.

For example this converts values in a map to json-encoded strings:

(defn- vals-lift [f m]
  (reduce (fn [acc [k v]] (assoc acc k (f v))) {} (seq m)))

(def #^{:private true} vals2json (partial vals-lift json-str))

[ 
http://github.com/kunley/clojure-couchdb/blob/master/src/couchdb/client.clj#L206
]

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to