Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made Atream.Iter an IFn, so can act as generator

  • Loading branch information...
commit daab7f25995d9922f04a3b43d9a5e8d5fefcfa43 1 parent 6254b8d
@richhickey richhickey authored
Showing with 8 additions and 10 deletions.
  1. +4 −9 src/clj/clojure/core.clj
  2. +4 −1 src/jvm/clojure/lang/AStream.java
View
13 src/clj/clojure/core.clj
@@ -1299,7 +1299,7 @@
(. ref (touch))
(. ref (get)))
-(def #^{:tag clojure.lang.Closer} *io-context* nil)
+(def *io-context* nil)
(defmacro sync
"transaction-flags => TBD, pass nil for now
@@ -1316,8 +1316,6 @@
(. clojure.lang.LockingTransaction
(runInTransaction (fn [] ~@body)))))
-
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fn stuff ;;;;;;;;;;;;;;;;
@@ -1995,17 +1993,14 @@
"If an io! block occurs in a transaction, throws an
IllegalStateException, else runs body in an implicit do. If the
first expression in body is a literal string, will use that as the
- exception message. Establishes a dynamic io context for use with io-scope."
+ exception message."
[& body]
(let [message (when (string? (first body)) (first body))
body (if message (rest body) body)]
`(if (clojure.lang.LockingTransaction/isRunning)
(throw (new IllegalStateException ~(or message "I/O in transaction")))
- (binding [*io-context* (clojure.lang.Closer.)]
- (try
- ~@body
- (finally
- (.close *io-context*)))))))
+ (binding [*io-context* true]
+ ~@body))))
(def *scope* nil)
View
5 src/jvm/clojure/lang/AStream.java
@@ -47,7 +47,7 @@ final synchronized public Iter iter() {
return iter = new Iter(this);
}
- static public class Iter {
+ static public class Iter extends AFn{
final AStream s;
Iter(AStream s) {
@@ -96,6 +96,9 @@ final public Object next(Object eos) {
}
}
+ public Object invoke(Object arg1) throws Exception {
+ return next(arg1);
+ }
}
static class Seq extends ASeq {
Please sign in to comment.
Something went wrong with that request. Please try again.