Skip to content

Instantly share code, notes, and snippets.

@pnf pnf/recursive-consume.clj
Last active Aug 29, 2015

Embed
What would you like to do?
user> (clojure.pprint/pprint (macroexpand-all
'(defn consume [c] (a/go (let [n (a/<! c)]
(when (zero? (mod n 10000)) (println n)))
(consume c)))))
(def
consume
(fn*
([c]
(let*
[c__8709__auto__
(clojure.core.async/chan 1)
captured-bindings__8710__auto__
(. clojure.lang.Var getThreadBindingFrame)]
(clojure.core.async.impl.dispatch/run
(fn*
([]
(let*
[f__8711__auto__
(fn*
state-machine__8527__auto__
([]
(let*
[statearr-10956
(new java.util.concurrent.atomic.AtomicReferenceArray 8)]
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10956
0
state-machine__8527__auto__)
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10956
1
1)
statearr-10956))
([state_10955]
(let*
[old-frame__8528__auto__
(. clojure.lang.Var getThreadBindingFrame)
ret-value__8529__auto__
(try
(.
clojure.lang.Var
resetThreadBindingFrame
(clojure.core.async.impl.ioc-macros/aget-object
state_10955
3))
(loop*
[]
(let*
[result__8530__auto__
(let*
[G__10957
(clojure.core/int
(clojure.core.async.impl.ioc-macros/aget-object
state_10955
1))]
(case*
G__10957
0
0
(throw
(new
java.lang.IllegalArgumentException
(clojure.core/str
"No matching clause: "
G__10957)))
{1
[1
(let*
[inst_10949 c]
(clojure.core.async.impl.ioc-macros/take!
state_10955
2
inst_10949))],
2
[2
(let*
[inst_10951
(clojure.core.async.impl.ioc-macros/aget-object
state_10955
2)
n
inst_10951
inst_10952
(do (if (zero? (mod n 10000)) (do (println n))))
inst_10953
(consume c)
state_10955
(let*
[statearr-10958 state_10955]
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10958
7
inst_10952)
statearr-10958)]
(clojure.core.async.impl.ioc-macros/return-chan
state_10955
inst_10953))]}
:compact
:int))]
(if
(
clojure.core/identical? result__8530__auto__ :recur)
(recur)
result__8530__auto__)))
(catch
java.lang.Throwable
ex__8531__auto__
(let*
[statearr-10959 state_10955]
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10959
clojure.core.async.impl.ioc-macros/CURRENT-EXCEPTION
ex__8531__auto__)
statearr-10959)
(clojure.core.async.impl.ioc-macros/process-exception
state_10955)
:recur)
(finally
(.
clojure.lang.Var
resetThreadBindingFrame
old-frame__8528__auto__)))]
(if
(clojure.core/identical? ret-value__8529__auto__ :recur)
(recur state_10955)
ret-value__8529__auto__))))
state__8712__auto__
(let*
[statearr-10960 (f__8711__auto__
)]
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10960
clojure.core.async.impl.ioc-macros/USER-START-IDX
c__8709__auto__)
(clojure.core.async.impl.ioc-macros/aset-object
statearr-10960
clojure.core.async.impl.ioc-macros/BINDINGS-IDX
captured-bindings__8710__auto__)
statearr-10960)]
(clojure.core.async.impl.ioc-macros/run-state-machine-wrapped
state__8712__auto__)))))
c__8709__auto__))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.