clojure.core/intern¶
Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name symbol. Returns the var.
Examples¶
Note by phreed¶
"The Namespace system maintains global maps of symbols to Var objects (see Namespaces). If a def expression does not find an interned entry in the current namespace for the symbol being def-ed, it creates one, otherwise it uses the existing Var. This find-or-create process is called interning. This means that, unless they have been unmap-ed, Var objects are stable references and need not be looked up every time. It also means that namespaces constitute a global environment in which, as described in Evaluation, the compiler attempts to resolve all free symbols as Vars.
"The var special form or the #' reader macro (see Reader) can be used to get an interned Var object instead of its current value."
-- [https://clojure.org/reference/vars]
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.