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 y
ataggart 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
Groups "Clojure" group.
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 wro
(: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 wh
Hi,
On 11 Okt., 09:22, HiHeelHottie 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 true} my-map {:a :b :c :
;; 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
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" gro