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.
By private var what one means is a local variable.
If you want a private variable use a let binding:
(let [my-private-var "Something not to be shared"]
(defn my-public-fn
"Do something"
[a b]
(str a b my-private-var)))
If you need the private variable to be mutable, use a ref and dosync
changes on it. That goes a long way towards correctness.
Albert
--
http://albert.rierol.net
--
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