summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2007-12-10 20:52:12 +0000
committerRich Hickey <richhickey@gmail.com>2007-12-10 20:52:12 +0000
commit30ce439346a5ed5aa1a7189ff1d932854486f0d3 (patch)
tree48fa5d32919f217839cafe52d960e9d053cb8e41
parente997be6fcd8fa7f4529de3767e6cd799b6687416 (diff)
added with-open
-rw-r--r--src/boot.clj8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/boot.clj b/src/boot.clj
index 2570a060..74e0989c 100644
--- a/src/boot.clj
+++ b/src/boot.clj
@@ -667,6 +667,12 @@
([stream eof-error? eof-value recursive?]
(. clojure.lang.LispReader (read stream eof-error? eof-value recursive?))))
+(defmacro with-open [rdr init & body]
+ `(let [~rdr ~init]
+ (try-finally
+ (do ~@body)
+ (. ~rdr (close)))))
+
(defmacro doto [x & members]
(let [gx (gensym)]
`(let [~gx ~x]
@@ -824,7 +830,7 @@
make-proxy implement
prn print newline *out* *current-namespace* *print-meta*
doto memfn
- read *in*
+ read *in* with-open
time
int long float double short byte boolean char
aget aset aset-boolean aset-int aset-long aset-float aset-double aset-short aset-byte