diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-05-13 23:40:02 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-05-13 23:40:02 +0000 |
commit | fed833d8a117ea137c008bde10dd011d3d7c2b97 (patch) | |
tree | b41305de9c5c111369900dca47c3c6026a2edf6e /src | |
parent | 56dc8bc5e6fdfd3e358e4c0d0428ce3067485f4d (diff) |
steps in improving modularity - moving classname resolution towards consumer in: ns - wraps require and use calls in with-loading-context
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/core.clj | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 62da5a61..a65443da 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -3447,6 +3447,15 @@ (def gen-class) +(defmacro with-loading-context [& body] + `((fn this# [] + (. clojure.lang.Var (pushThreadBindings {clojure.lang.Compiler/LOADER + (-> this# .getClass .getClassLoader)})) + (try + ~@body + (finally + (. clojure.lang.Var (popThreadBindings))))))) + (defmacro ns "Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) @@ -3485,7 +3494,7 @@ (when gen-class-clause (list* `gen-class :name (.replace (str name) \- \_) :impl-ns name :main true (next gen-class-clause))) references (remove #(= :gen-class (first %)) references)] - `(do + `(with-loading-context (clojure.core/in-ns '~name) ~@(when gen-class-call (list gen-class-call)) ~@(when (and (not= name 'clojure.core) (not-any? #(= :refer-clojure (first %)) references)) @@ -3643,6 +3652,7 @@ ;; Public + (defn require "Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies |