Useful namespace macros.
Some macros taken from clojure/clojure-contrib.
Useful namespace macros. Some macros taken from [clojure/clojure-contrib](https://clojure.github.io/clojure-contrib/with-ns-api.html).
(with-context-ns var [attr-map? references*] exprs*)
Just like with-ns
but brings in a context into the temporary namespace.
The var parameter is the variable to pass to the temporary namespace.
(let [abind 'someval]
(with-context-ns
abind
[(:require [clojure.string :as s])]
(s/capitalize (str (name abind)))))
See [[clojure.core/ns]].
Just like [[with-ns]] but brings in a context into the temporary namespace. The **var** parameter is the variable to pass to the temporary namespace. ## Example ``` (let [abind 'someval] (with-context-ns abind [(:require [clojure.string :as s])] (s/capitalize (str (name abind))))) ``` See [[clojure.core/ns]].
(with-ns [attr-map? references*] exprs*)
Just like with-temp-ns
but allows an [[clojure.core/ns]]
specification (not including the namespace name).
(with-ns
[(:require [clojure.string :as s])]
(s/capitalize "here"))
See [[clojure.core/ns]].
Just like [[with-temp-ns]] but allows an [[clojure.core/ns]] specification (not including the namespace name). ## Example ``` (with-ns [(:require [clojure.string :as s])] (s/capitalize "here")) ``` See [[clojure.core/ns]].
(with-other-ns ns & body)
Evaluates body in another namespace. ns is either a namespace object or a symbol. This makes it possible to define functions in namespaces other than the current one.
Evaluates body in another namespace. ns is either a namespace object or a symbol. This makes it possible to define functions in namespaces other than the current one.
(with-temp-ns & body)
Evaluates body in an anonymous namespace, which is then immediately removed. The temporary namespace will 'refer' clojure.core.
Evaluates body in an anonymous namespace, which is then immediately removed. The temporary namespace will 'refer' clojure.core.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close