aboutsummaryrefslogtreecommitdiff
path: root/def.clj
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2008-06-28 20:03:16 +0000
committerscgilardi <scgilardi@gmail.com>2008-06-28 20:03:16 +0000
commitcef84addca7796ec9387d2e87c40447e9fc541bd (patch)
tree5a0513ff879b2704217e97c3e2848192efcf93f3 /def.clj
parent8aca82ac404998a7584d99e1039e60e8ac5b3a20 (diff)
add pred.clj, various predicates for convenience, readability
Diffstat (limited to 'def.clj')
-rw-r--r--def.clj7
1 files changed, 7 insertions, 0 deletions
diff --git a/def.clj b/def.clj
index a198795b..367d1fda 100644
--- a/def.clj
+++ b/def.clj
@@ -17,6 +17,13 @@
(clojure/in-ns 'def)
(clojure/refer 'clojure)
+(defmacro init-once
+ "Initializes a var exactly once. The var must already exist."
+ [var init]
+ `(let [v# (resolve '~var)]
+ (when-not (.isBound v#)
+ (.bindRoot v# ~init))))
+
(defmacro defvar
"Defines a var with an optional intializer and doc string"
([name]