special form (repl) | since v0.0-927 | clojure.core/in-ns | Edit |
(in-ns name)
Only usable from a REPL.
Changes to the namespace name
, creating it if needed.
Sets *cljs-ns*
to the namespace name
.
(in-ns 'foo.core)
Sets *cljs-ns* to the namespace named by the symbol, creating it if needed.
(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})))