Skip to content

Commit 671e8a6

Browse files
committed
less ctx
1 parent 39ca5fe commit 671e8a6

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/sci/impl/namespaces.cljc

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -517,26 +517,27 @@
517517
(sci-ns-refers* ctx sci-ns)
518518
(sci-ns-imports* ctx sci-ns))))
519519

520-
(defn sci-ns-unmap [ctx sci-ns sym]
521-
(assert (symbol? sym)) ; protects :aliases, :imports, :obj, etc.
522-
(swap! (:env ctx)
523-
(fn [env]
524-
(let [name (sci-ns-name ctx sci-ns)]
525-
(update-in env [:namespaces name]
526-
(fn [the-ns-map]
527-
(cond (contains? (:refers the-ns-map) sym)
528-
(-> (update the-ns-map :refers dissoc sym)
529-
;; remove lingering var that may have been
530-
;; overwritten before, see #637
531-
(dissoc the-ns-map sym))
532-
(contains? the-ns-map sym)
533-
(dissoc the-ns-map sym)
534-
(or
535-
(contains? (:imports env) sym)
536-
(contains? (:imports the-ns-map) sym))
537-
;; nil marks the imported class as unmapped
538-
(update the-ns-map :imports assoc sym nil)
539-
:else the-ns-map))))))
520+
(defn sci-ns-unmap [sci-ns sym]
521+
(let [ctx (store/get-ctx)]
522+
(assert (symbol? sym)) ; protects :aliases, :imports, :obj, etc.
523+
(swap! (:env ctx)
524+
(fn [env]
525+
(let [name (sci-ns-name ctx sci-ns)]
526+
(update-in env [:namespaces name]
527+
(fn [the-ns-map]
528+
(cond (contains? (:refers the-ns-map) sym)
529+
(-> (update the-ns-map :refers dissoc sym)
530+
;; remove lingering var that may have been
531+
;; overwritten before, see #637
532+
(dissoc the-ns-map sym))
533+
(contains? the-ns-map sym)
534+
(dissoc the-ns-map sym)
535+
(or
536+
(contains? (:imports env) sym)
537+
(contains? (:imports the-ns-map) sym))
538+
;; nil marks the imported class as unmapped
539+
(update the-ns-map :imports assoc sym nil)
540+
:else the-ns-map)))))))
540541
nil)
541542

542543
(defn sci-ns-unalias [ctx sci-ns sym]
@@ -1511,7 +1512,7 @@
15111512
'ns-publics (copy-var sci-ns-publics clojure-core-ns {:name 'ns-publics})
15121513
'ns-refers (copy-var sci-ns-refers clojure-core-ns {:name 'ns-refers})
15131514
'ns-map (copy-var sci-ns-map clojure-core-ns {:name 'ns-map})
1514-
'ns-unmap (copy-var sci-ns-unmap clojure-core-ns {:ctx true :name 'ns-unmap})
1515+
'ns-unmap (copy-var sci-ns-unmap clojure-core-ns {:name 'ns-unmap})
15151516
'ns-unalias (copy-var sci-ns-unalias clojure-core-ns {:ctx true :name 'ns-unalias})
15161517
'ns-name (copy-var sci-ns-name clojure-core-ns {:name 'ns-name :ctx true})
15171518
'odd? (copy-core-var odd?)

0 commit comments

Comments
 (0)