Commit 4f86b74 1 parent 2e4d6e0 commit 4f86b74 Copy full SHA for 4f86b74
File tree 2 files changed +24
-22
lines changed
2 files changed +24
-22
lines changed Original file line number Diff line number Diff line change 64
64
#? (:clj (.get dvals)
65
65
:cljs @dvals))
66
66
67
+ (deftype TBox #? (:clj [thread ^:volatile-mutable val]
68
+ :cljs [thread ^:mutable val])
69
+ t /IBox
70
+ (setVal [this v]
71
+ (set! val v))
72
+ (getVal [this] val))
73
+
67
74
(defn clone-thread-binding-frame ^Frame []
68
75
(let [^Frame f #?(:clj (.get dvals)
69
76
:cljs @dvals)]
73
80
#? (:clj (.set dvals frame)
74
81
:cljs (reset! dvals frame)))
75
82
76
- (deftype TBox #? (:clj [thread ^:volatile-mutable val]
77
- :cljs [thread ^:mutable val])
78
- t /IBox
79
- (setVal [this v]
80
- (set! val v))
81
- (getVal [this] val))
82
-
83
83
(declare var? )
84
84
85
85
(defn dynamic-var? [v]
259
259
(not (instance? SciUnbound root)))
260
260
t /IBox
261
261
(setVal [this v]
262
- (let [b (get-thread-binding this)]
263
- (if (some? b)
264
- #?(:clj
265
- (let [t (.-thread b)]
266
- (if (not (identical? t (Thread/currentThread )))
267
- (throw (new IllegalStateException
268
- (str " Can't change/establish root binding of " this " with set" )))
269
- (t/setVal b v)))
270
- :cljs (t/setVal b v))
271
- (throw (new #?(:clj IllegalStateException :cljs js/Error)
272
- (str " Can't change/establish root binding of " this " with set" ))))))
262
+ (if-let [b (get-thread-binding this)]
263
+ #?(:clj
264
+ (let [t (.-thread b)]
265
+ (if (not (identical? t (Thread/currentThread )))
266
+ (throw (new IllegalStateException
267
+ (format " Can't set!: %s from non-binding thread" sym)))
268
+ (t/setVal b v)))
269
+ :cljs (t/setVal b v))
270
+ (throw (new #?(:clj IllegalStateException :cljs js/Error)
271
+ (str " Can't change/establish root binding of " this " with set" )))))
273
272
(getVal [this] root)
274
273
#? (:clj clojure.lang.IDeref :cljs IDeref)
275
274
(#?(:clj deref
276
275
:cljs -deref) [this]
277
276
(if thread-bound
278
- (or ( when -let [tbox (get-thread-binding this)]
279
- (t/getVal tbox) )
280
- root)
277
+ (if -let [tbox (get-thread-binding this)]
278
+ (t/getVal tbox)
279
+ root)
281
280
root))
282
281
Object
283
282
(toString [_]
Original file line number Diff line number Diff line change 35
35
#_#_:sci.impl/built-in true })]
36
36
(is (= [11 10 ] (sci/eval-string
37
37
" [(binding [*x* (fn [] 11)] (*x*)) (*x*)]"
38
- {:bindings {'*x* x}}))))))
38
+ {:bindings {'*x* x}})))))
39
+ (testing " dynamic binding of false works"
40
+ (is (false ? (sci/eval-string
41
+ " (def ^:dynamic x nil) (binding [x false] x)" )))))
39
42
40
43
(deftest redefine-var-test
41
44
(is (= 11 (eval* "
You can’t perform that action at this time.
0 commit comments