Creating, setting and inspecting namespaces.

By design, there is no namespace type.

Primary

In this section: all create! meta munge ns? remove!

all

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (all)

Type signature:
  • () → #{Symbol}

Returns the set of symbols representing all available namespaces.

See also: ns?, mappings

create!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (create! symbol)

Type signature:
  • (Symbol) → nil

Creates a namespace named by the symbol. Returns nil. Does nothing if namespace already exists.

See also: ns?, mappings, remove!, intern!

meta

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (meta symbol)

Type signature:
  • (Symbol) → {}

Returns metadata map for a namespace named by the symbol.

munge

Available since version 1.0 (alias of clojure.core/namespace-munge)

not referred automatically

Usage:
  • (munge ns)

Type signature:
  • (Symbol) → String+

Returns a host lib name for a namespace named by a ns symbol.

See also: ns?

ns?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (ns? symbol)

Type signature:
  • (Symbol) → Boolean+

Returns true if a namespace named by the symbol is present, otherwise returns false.

See also: all, mappings, munge

remove!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (remove! symbol)

Type signature:
  • (Symbol) → nil

Removes a namespace named by the symbol. Returns nil. Does nothing if namespace does not exists.

See also: ns?, mappings, create!, unmap!

Mappings

aliases

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (aliases symbol)

Type signature:
  • (Symbol) → (I IReference IMutable)

Returns a mutable reference to the map of all the aliases for the namespace named by the symbol.

import!

Available since version 1.0 (view source)

not referred automatically

MACRO (import! ns & import-symbols-or-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 namespace identified by ns symbol.

Use :import in the ns macro in preference to calling this directly.

imports

Available since version 1.0 (alias of clojure.core/ns-imports)

not referred automatically

Usage:
  • (imports ns)

Type signature:
  • (Symbol) → {Symbol Class+}

Returns a map of the import mappings for the namespace named by the ns symbol.

intern!

Available since version 1.0 (alias of clojure.core/intern)

not referred automatically

Usage:
  • (intern! ns name)

  • (intern! ns name val)

Type signatures:
  • (Symbol ⨯ Symbol) → Var

  • (Symbol ⨯ Symbol ⨯ Any) → Var

Finds or creates a var named by the symbol name in the namespace named by the ns symbol, setting its root binding to val if supplied. The namespace ns must exist.

The var will adopt any metadata from the name symbol. Returns the var.

interns

Available since version 1.0 (alias of clojure.core/ns-interns)

not referred automatically

Usage:
  • (interns ns)

Type signature:
  • (Symbol) → {Symbol Var}

Returns a map of the intern mappings for the namespace named by the ns symbol.

mappings

Available since version 1.0 (alias of clojure.core/ns-map)

not referred automatically

Usage:
  • (mappings ns)

Type signature:
  • (Symbol) → {Symbol (U Var Class+)}

Returns a map of all the mappings for the namespace named by the ns symbol.

publics

Available since version 1.0 (alias of clojure.core/ns-publics)

not referred automatically

Usage:
  • (publics ns)

Type signature:
  • (Symbol) → {Symbol Var}

Returns a map of the public intern mappings for the namespace named by the ns symbol.

refer!

Available since version 1.0 (alias of clojure.core/refer*)

not referred automatically

Usage:
  • (refer! ons ns-sym & filters)

Type signature:
  • (Symbol ⨯ Symbol ⨯ (Va Any)) → nil

refers to all public vars of ns-sym in ons, 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 ons namespace. Throws an exception if name is already mapped to something else in the ons. 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.

refers

Available since version 1.0 (alias of clojure.core/ns-refers)

not referred automatically

Usage:
  • (refers ns)

Type signature:
  • (Symbol) → {Symbol Var}

Returns a map of the refer mappings for the namespace named by the ns symbol.

resolve

Available since version 1.0 (alias of clojure.core/ns-resolve)

not referred automatically

Usage:
  • (resolve ns sym)

  • (resolve ns env sym)

Type signatures:
  • (Symbol ⨯ Symbol) → (U Var Class+)

  • (Symbol ⨯ ILookup ⨯ Symbol) → (U Var Class+)

Returns the var or host Class to which a symbol sym will be resolved in the namespace named by ns symbol (unless found in the environment env), else nil.

Note that if sym is fully qualified, the var/Class to which it resolves need not be present in the ns.

See also: mappings, intern!, refer!, unmap!

unmap!

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (unmap! ns symbol)

Type signature:
  • (Symbol ⨯ Symbol) → nil

Removes the mappings for the symbol from the namespace named by the ns. Returns nil. Does nothing if mapping does not exists.