File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 269
269
" Forks a context (as produced with `init`) into a new context. Any new
270
270
vars created in the new context won't be visible in the original
271
271
context."
272
- [ctx]
273
- (update ctx :env (fn [env] (atom @env))))
272
+ ([ctx]
273
+ (update ctx :env (fn [env] (atom @env))))
274
+ ([ctx {:keys [clone-vars]}]
275
+ (update ctx :env (fn [env]
276
+ (let [env @env
277
+ env (if clone-vars
278
+ (update env :namespaces
279
+ (fn [namespaces]
280
+ (update-vals namespaces (fn [namespace]
281
+ (update-vals namespace
282
+ (fn [var]
283
+ (if (utils/var? var)
284
+ (.clone ^sci.lang.Var var)
285
+ var)))))))
286
+
287
+ env)]
288
+ (atom env))))))
274
289
275
290
(defn eval-string*
276
291
" Evaluates string `s` in the context of `ctx` (as produced with
Original file line number Diff line number Diff line change 249
249
(apply @this a b c d e f g h i j k l m n o p q r s t rest))
250
250
#?(:clj
251
251
(applyTo [this args]
252
- (apply @this args))))
252
+ (apply @this args)))
253
+ #?@(:clj [Cloneable
254
+ (clone [_this]
255
+ (new Var root sym meta thread-bound needs-ctx watches))]))
253
256
254
257
#?(:clj
255
258
; ; Use public interface for print-method so it can be overriden in bb itself
You can’t perform that action at this time.
0 commit comments