(refer ns-sym & filters)
refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current namespace. Filters can be used to select a subset, via inclusion or exclusion, or to provide a mapping to a symbol different from the var's name, in order to prevent clashes. Use :use in the ns macro in preference to calling this directly.
user=> (refer 'clojure.string :only '[capitalize trim])
nil
user=> (capitalize (trim " hOnduRAS "))
"Honduras"
user=> (refer 'clojure.string
:rename '{capitalize cap, trim trm})
WARNING: replace already refers to: #'clojure.core/replace in namespace: user, being replaced by: #'clojure.string/replace
WARNING: reverse already refers to: #'clojure.core/reverse in namespace: user, being replaced by: #'clojure.string/reverse
nil
user=> (cap (trm " hOnduRAS "))
"Honduras"
user=> (join \\, [1 2 3])
"1,2,3"
;;; `:only' accepts only original names.
;; wrong
user=> (refer 'clojure.string
:rename '{capitalize cap, trim trm}
:only '[cap trm])
IllegalAccessError cap does not exist clojure.core/refer (core.clj:3849)
;; right
user=> (refer 'clojure.string
:rename '{capitalize cap, trim trm}
:only '[capitalize trim])
nil
;; work well
user=> (cap (trm " hOnduRAS "))
"Honduras"
;; and also, cannot use either of them.
user=> (join \\, [1 2 3])
CompilerException java.lang.RuntimeException: Unable to resolve symbol: join in this context, compiling:(NO_SOURCE_PATH:1:1)