such.immigration
Potemkin’s import-vars
is the most reliable way I know to make a namespace that gathers vars from several namespaces and presents them as a unified API. This namespace builds on it. See the tests and commons.clojure.core for two examples of creating a “favorite functions” namespace that can be included everywhere with (for example) (ns my.ns (:use my.clojure.core))
.
import-all-vars
macro
(import-all-vars & ns-syms)
Import all public vars from the namespaces, using Potemkin’s import-vars
.
(import-all-vars clojure.set) ; note namespace is unquoted.
import-prefixed-vars
macro
(import-prefixed-vars ns-sym prefix)
Import all public vars from the namespace, using Potemkin’s import-vars
. Within the current namespace, the imported vars are prefixed by prefix
, a symbol.
(import-prefixed-vars clojure.string str-) ; note lack of quotes
(str-trim " f ") => "f"
import-vars
macro
(import-vars & namespace-and-var-descriptions)
Import named vars from the named namespaces and make them (1) public in this namespace and (2) available for refer
by namespaces that require this one. See Potemkin for more.
(import-vars [clojure.math.combinatorics
count-permutations permutations]
[clojure.data.json
write-str])