zensols.actioncli.ns
Useful namespace macros.
Some macros taken from clojure/clojure-contrib.
with-context-ns
macro
(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.
Example
(let [abind 'someval]
(with-context-ns
abind
[(:require [clojure.string :as s])]
(s/capitalize (str (name abind)))))
See clojure.core/ns.
with-ns
macro
(with-ns [attr-map? references*] exprs*)
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
macro
(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.
with-temp-ns
macro
(with-temp-ns & body)
Evaluates body in an anonymous namespace, which is then immediately removed. The temporary namespace will ‘refer’ clojure.core.