special form (repl) | since v0.0-927 | Edit |
Only usable from a REPL.
Load a namespace and all of its dependencies into the evaluation environment. The environment is responsible for ensuring that each namespace is loaded once and only once.
(load-namespace 'clojure.set)
(def default-special-fns
(let [load-file-fn
(fn self
([repl-env env form]
(self repl-env env form nil))
([repl-env env [_ file :as form] opts]
(load-file repl-env file opts)))
in-ns-fn
(fn self
([repl-env env form]
(self repl-env env form nil))
([repl-env env [_ [quote ns-name] :as form] _]
;; guard against craziness like '5 which wreaks havoc
(when-not (and (= quote 'quote) (symbol? ns-name))
(throw (IllegalArgumentException. "Argument to in-ns must be a symbol.")))
(when-not (ana/get-namespace ns-name)
(swap! env/*compiler* assoc-in [::ana/namespaces ns-name] {:name ns-name})
(-evaluate repl-env "" 1
(str "goog.provide('" (comp/munge ns-name) "');")))
(set! ana/*cljs-ns* ns-name)))
load-fn
(fn self
([repl-env env form]
(self env repl-env form nil))
([repl-env env [_ & paths :as form] opts]
(let [cp-paths (map load-path->cp-path paths)]
(run! #(load-file repl-env % opts) cp-paths))))]
(wrap-special-fns wrap-self
{'in-ns in-ns-fn
'clojure.core/in-ns in-ns-fn
'load-file load-file-fn
'clojure.core/load-file load-file-fn
'load-namespace
(fn self
([repl-env env form]
(self env repl-env form nil))
([repl-env env [_ ns :as form] opts]
(load-namespace repl-env ns opts)))
'load load-fn
'clojure.core/load load-fn})))