Namespaces are mappings from simple (unqualified) symbols to Vars and/or Classes. Vars can be interned in a namespace, using def or any of its variants, in which case they have a simple symbol for a name and a reference to their containing namespace, and the namespace maps that symbol to the same var. A namespace can also contain mappings from symbols to vars interned in other namespaces, by using refer, or from symbols to Class objects, by using import. Note that namespaces are first-class, they can be enumerated etc. Namespaces are also dynamic, they can be created, removed and modified at runtime, at the Repl etc.
A newly created namespace contains mappings for the classnames in java.lang, and nothing else. In order to access the names from the clojure namespace you must execute (clojure/refer 'clojure). The user namespace at the Repl has already done this.
The current namespace, *ns* can and should be set only with a call to in-ns.
(in-ns ns-symbol)
Sets *ns* to the namespace named by the symbol, creating it if needed.
(create-ns ns-symbol)
Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing namespace of the same name.
(find-ns ns-symbol)
Returns the namespace named by the symbol or nil if it doesn't exist.
(all-ns)
Returns a sequence of all namespaces.
(remove-ns ns-symbol)
Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace.
(import import-lists+)
import-list => (package-symbol class-name-symbols*)
For each name in class-name-symbols, adds a mapping from name to the class named by "package.name" to the current namespace.
(import '(java.util Date Timer Random)
'(java.sql Connection Statement))
(refer ns-symbol filters*)
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.
(clojure/refer 'clojure :exclude '(array-map) :rename '{+ plus - minus})
(ns-name ns)
Returns the name of the namespace, a symbol.
(ns-map ns)
Returns a map of all the mappings for the namespace.
(ns-interns ns)
Returns a map of the intern mappings for the namespace.
(ns-publics ns)
Returns a map of the public intern mappings for the namespace.
(ns-imports ns)
Returns a map of the import mappings for the namespace.
(ns-refers ns)
Returns a map of the refer mappings for the namespace.
(ns-resolve ns symbol)
Returns the var or Class to which a symbol will be resolved in the namespace. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace.
(resolve symbol)
same as (ns-resolve *ns* symbol)
(ns-unmap ns symbol)
Removes the mappings for the symbol from the namespace.
(ns-unmap *ns* 'Date)
(name symbol-or-keyword)
Returns the name String.
(namespace symbol-or-keyword)
Returns the namespace String or nil if not present.