aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/with_ns.clj
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2010-01-20 15:39:56 -0500
committerStuart Sierra <mail@stuartsierra.com>2010-01-20 15:39:56 -0500
commit2ede388a9267d175bfaa7781ee9d57532eb4f20f (patch)
treebb42002af196405d7e25cc4e30b4c1c9de5c06d5 /src/clojure/contrib/with_ns.clj
parent1bc820d96048a6536706ff999e9892649b53c700 (diff)
Move source files into Maven-style directory structure.
Diffstat (limited to 'src/clojure/contrib/with_ns.clj')
-rw-r--r--src/clojure/contrib/with_ns.clj38
1 files changed, 0 insertions, 38 deletions
diff --git a/src/clojure/contrib/with_ns.clj b/src/clojure/contrib/with_ns.clj
deleted file mode 100644
index d874a4a5..00000000
--- a/src/clojure/contrib/with_ns.clj
+++ /dev/null
@@ -1,38 +0,0 @@
-;;; with_ns.clj -- temporary namespace macro
-
-;; by Stuart Sierra, http://stuartsierra.com/
-;; March 28, 2009
-
-;; Copyright (c) Stuart Sierra, 2009. All rights reserved. The use
-;; and distribution terms for this software are covered by the Eclipse
-;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-;; which can be found in the file epl-v10.html at the root of this
-;; distribution. By using this software in any fashion, you are
-;; agreeing to be bound by the terms of this license. You must not
-;; remove this notice, or any other, from this software.
-
-
-(ns
- #^{:author "Stuart Sierra",
- :doc "Temporary namespace macro"}
- clojure.contrib.with-ns)
-
-(defmacro with-ns
- "Evaluates body in another namespace. ns is either a namespace
- object or a symbol. This makes it possible to define functions in
- namespaces other than the current one."
- [ns & body]
- `(binding [*ns* (the-ns ~ns)]
- ~@(map (fn [form] `(eval '~form)) body)))
-
-(defmacro with-temp-ns
- "Evaluates body in an anonymous namespace, which is then immediately
- removed. The temporary namespace will 'refer' clojure.core."
- [& body]
- `(try
- (create-ns 'sym#)
- (let [result# (with-ns 'sym#
- (clojure.core/refer-clojure)
- ~@body)]
- result#)
- (finally (remove-ns 'sym#))))