Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-16 Thread Steven E. Harris
ataggart alex.tagg...@gmail.com writes: It's fairly common to let over a function, e.g.: So common, in fact, that Doug Hoyte wrote a book about it: Let Over Lambda http://www.letoverlambda.com/ -- Steven E. Harris -- You received this message because you are subscribed to the Google

Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-16 Thread ka
I've been wondering about having let over defn, I have the following concerns - 1. Not recommended in the docs http://clojure.org/special_forms#Special%20Forms--%28def%20symbol%20init?%29 says - Using def to modify the root value of a var at other than the top level is usually an indication that

Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-11 Thread HiHeelHottie
I want to define and use a map that is private to a namespace and used by several functions in that namespace. Is the idiomatic way simply to def it within the namespace? Is there another way to hide it? -- You received this message because you are subscribed to the Google Groups Clojure

Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-11 Thread Shantanu Kumar
;; some_ns/internal.clj (ns some-ns.internal) (def private-map {:k1 10 :k2 20}) ;;end-of-file ;; some_ns.clj (ns some-ns (:use some-ns.internal)) ;; ..functions.. (defn foo [] ;; do something with private-map ..) ;;end-of-file This is how

Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-11 Thread Meikel Brandmeyer
Hi, On 11 Okt., 09:22, HiHeelHottie hiheelhot...@gmail.com wrote: I want to define and use a map that is private to a namespace and used by several functions in that namespace.  Is the idiomatic way simply to def it within the namespace?  Is there another way to hide it? (def ^{:private

Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-11 Thread lprefontaine
(:use [clojure.contrib.def]) (defvar- x ...) A bit shorter than writing the meta-data by hand. Def provides a number of other interesting shortcuts. Have a look at def.clj in contrib. I prefer to keep things private and avoid cluttering the use clause with a long :only list. I use :only only

Re: Idiomatic Way to Keep a Variable Private to a Namespace

2010-10-11 Thread ataggart
It's fairly common to let over a function, e.g.: (let [a (atom 0)] (defn next-id [] (swap! a inc))) In the above, the atom can only be referenced from within the lexical scope of the let, hence essentially private to the next-id function. On Oct 11, 8:03 am, lprefonta...@softaddicts.ca