summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);