summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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}