diff options
author | Christophe Grand <christophe@cgrand.net> | 2010-02-10 19:35:04 +0100 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-10-15 07:25:19 -0400 |
commit | 4b9d7ba4812a9540afcaf256dc2f58da1e173988 (patch) | |
tree | 13221cf0f5551a1fcfae1c307f7784e8011d7f3b | |
parent | da538484009666d17015a5f275d257c2e2b8120f (diff) |
Add an optional environment argument to #'resolve and ns-resolve. See #263
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | src/clj/clojure/core.clj | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 83297d20..ee6bc053 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -3733,19 +3733,23 @@ (defn ns-resolve "Returns the var or Class to which a symbol will be resolved in the - namespace, else nil. Note that if the symbol is fully qualified, - the var/Class to which it resolves need not be present in the - namespace." + 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] - (clojure.lang.Compiler/maybeResolveIn (the-ns ns) sym)) + ([ns sym] + (ns-resolve ns nil sym)) + ([ns env sym] + (when-not (contains? env sym) + (clojure.lang.Compiler/maybeResolveIn (the-ns ns) sym)))) (defn resolve - "same as (ns-resolve *ns* symbol)" + "same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)" {:added "1.0" :static true} - [sym] (ns-resolve *ns* sym)) + ([sym] (ns-resolve *ns* sym)) + ([env sym] (ns-resolve *ns* env sym))) (defn array-map "Constructs an array-map." |