ns-resolve

clojure.core

  • (ns-resolve ns sym)
  • (ns-resolve ns env sym)
Returns the var or Class to which a symbol will be resolved in the
namespace (unless found in the environement), else nil. Note that
if the symbol is fully qualified, the var/Class to which it resolves
need not be present in the namespace.

2 Examples top

  • user=> (defn f [n] (* n n n))
    #'user/f
    user=> ((ns-resolve *ns* (symbol "f")) 10)
    1000
  • ;; See also http://clojure.org/namespaces for information on namespaces in Clojure and how to inspect and manipulate them
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3868 top

(defn ns-resolve
  "Returns the var or Class to which a symbol will be resolved in the
  namespace (unless found in the environement), else nil.  Note that
  if the symbol is fully qualified, the var/Class to which it resolves
  need not be present in the namespace."
  {:added "1.0"
   :static true}
  ([ns sym]
    (ns-resolve ns nil sym))
  ([ns env sym]
    (when-not (contains? env sym)
      (clojure.lang.Compiler/maybeResolveIn (the-ns ns) sym))))
Vars in clojure.core/ns-resolve:
Used in 0 other vars

Comments top

1 comment(s) for ns-resolve.

The appropriate value for the env arg is what you get from the implicit &env arg available to a macro.

Log in to add a comment.