summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-08-12 20:26:17 +0000
committerRich Hickey <richhickey@gmail.com>2008-08-12 20:26:17 +0000
commit3f0c711fe4f7e05b4232d85f9f9d0f81e28d9c90 (patch)
treee48e47999dd41d5fc96542308e94f4e3904ffa5d /src
parent5c6454d0266ce16c54551e03321d846e91805d5f (diff)
added with-in-str
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/boot.clj8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj
index 7fbfd4d1..792cea31 100644
--- a/src/clj/clojure/boot.clj
+++ b/src/clj/clojure/boot.clj
@@ -2286,6 +2286,14 @@
~@body
(str s#))))
+(defmacro with-in-str
+ "Evaluates body in a context in which *in* is bound to a fresh
+ StringReader initialized with the string s."
+ [s & body]
+ `(with-open s# (-> (java.io.StringReader. ~s) clojure.lang.LineNumberingPushbackReader.)
+ (binding [*in* s#]
+ ~@body)))
+
(defn pr-str
"pr to a string, returning it"
{:tag String}