summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2010-04-14 20:17:58 -0400
committerRich Hickey <richhickey@gmail.com>2010-04-14 20:17:58 -0400
commita9953ba5834ae714cf767e73478a1c3c216561ac (patch)
tree26cdea8fd141e8b05109f4f666c71863a39ecf2f
parent12b5c5996dc2f9943f2fca075e94990a24cd7d37 (diff)
parent92e9c2d76f6b8d86789bc69496596a98d8b67228 (diff)
Merge branch 'master' of git@github.com:richhickey/clojure
-rw-r--r--src/clj/clojure/core.clj14
-rw-r--r--src/jvm/clojure/lang/Var.java2
2 files changed, 14 insertions, 2 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index a728bc0d..892eb081 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -553,7 +553,7 @@
;;;;;;;;;;;;;;;;at this point all the support for syntax-quote exists;;;;;;;;;;;;;;;;;;;;;;
(defmacro delay
"Takes a body of expressions and yields a Delay object that will
- invoke the body only the first time it is forced (with force), and
+ invoke the body only the first time it is forced (with force or deref/@), and
will cache the result and return it on all subsequent force
calls."
[& body]
@@ -3819,6 +3819,18 @@
current value plus any args"
[#^clojure.lang.Var v f & args] (.alterRoot v f args))
+(defn bound?
+ "Returns true if all of the vars provided as arguments have any bound value, root or thread-local.
+ Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided."
+ [& vars]
+ (every? #(.isBound #^clojure.lang.Var %) vars))
+
+(defn thread-bound?
+ "Returns true if all of the vars provided as arguments have thread-local bindings.
+ Implies that set!'ing the provided vars will succeed. Returns true if no vars are provided."
+ [& vars]
+ (every? #(.getThreadBinding #^clojure.lang.Var %) vars))
+
(defn make-hierarchy
"Creates a hierarchy object for use with derive, isa? etc."
[] {:parents {} :descendants {} :ancestors {}})
diff --git a/src/jvm/clojure/lang/Var.java b/src/jvm/clojure/lang/Var.java
index 2a603b03..ca429749 100644
--- a/src/jvm/clojure/lang/Var.java
+++ b/src/jvm/clojure/lang/Var.java
@@ -328,7 +328,7 @@ public static Associative getThreadBindings(){
return ret;
}
-final Box getThreadBinding(){
+public final Box getThreadBinding(){
if(count.get() > 0)
{
IMapEntry e = dvals.get().bindings.entryAt(this);