Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Created March 8, 2016 18:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save noisesmith/db3b90abb6b9e5f7f282 to your computer and use it in GitHub Desktop.
macro expansion of core.match with core.async
=> (pprint (macroexpand '(clojure.core.async/go (match/match [(+ 1 1) (* 1 1)] [0 0] :wat [2 1] :OK [_ _] :wat))))
(let*
[c__5997__auto__
(clojure.core.async/chan 1)
captured-bindings__5998__auto__
(clojure.lang.Var/getThreadBindingFrame)]
(clojure.core.async.impl.dispatch/run
(clojure.core/fn
[]
(clojure.core/let
[f__5999__auto__
(clojure.core/fn
state-machine__5821__auto__
([]
(clojure.core.async.impl.ioc-macros/aset-all!
(java.util.concurrent.atomic.AtomicReferenceArray. 7)
0
state-machine__5821__auto__
1
1))
([state_34927]
(clojure.core/let
[old-frame__5822__auto__
(clojure.lang.Var/getThreadBindingFrame)
ret-value__5823__auto__
(try
(clojure.lang.Var/resetThreadBindingFrame
(clojure.core.async.impl.ioc-macros/aget-object
state_34927
3))
(clojure.core/loop
[]
(clojure.core/let
[result__5824__auto__
(clojure.core/case
(clojure.core/int
(clojure.core.async.impl.ioc-macros/aget-object
state_34927
1))
1
(clojure.core/let
[inst_34925
(let*
[ocr-34919 (+ 1 1) ocr-34920 (* 1 1)]
(try
(clojure.core/cond
(clojure.core/= ocr-34919 0)
(try
(clojure.core/cond
(clojure.core/= ocr-34920 0)
:wat
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__34157__auto__
(if
(clojure.core/identical?
e__34157__auto__
clojure.core.match/backtrack)
(do (throw clojure.core.match/backtrack))
(throw e__34157__auto__))))
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__34157__auto__
(if
(clojure.core/identical?
e__34157__auto__
clojure.core.match/backtrack)
(do
(try
(clojure.core/cond
(clojure.core/= ocr-34919 2)
(try
(clojure.core/cond
(clojure.core/= ocr-34920 1)
:OK
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__34157__auto__
(if
(clojure.core/identical?
e__34157__auto__
clojure.core.match/backtrack)
(do (throw clojure.core.match/backtrack))
(throw e__34157__auto__))))
:else
(throw clojure.core.match/backtrack))
(catch
Exception
e__34157__auto__
(if
(clojure.core/identical?
e__34157__auto__
clojure.core.match/backtrack)
(do :wat)
(throw e__34157__auto__)))))
(throw e__34157__auto__)))))]
(clojure.core.async.impl.ioc-macros/return-chan
state_34927
inst_34925)))]
(if
(clojure.core/identical? result__5824__auto__ :recur)
(recur)
result__5824__auto__)))
(catch
java.lang.Throwable
ex__5825__auto__
(clojure.core.async.impl.ioc-macros/aset-all!
state_34927
clojure.core.async.impl.ioc-macros/CURRENT-EXCEPTION
ex__5825__auto__)
(clojure.core.async.impl.ioc-macros/process-exception
state_34927)
:recur)
(finally
(clojure.lang.Var/resetThreadBindingFrame
old-frame__5822__auto__)))]
(if
(clojure.core/identical? ret-value__5823__auto__ :recur)
(recur state_34927)
ret-value__5823__auto__))))
state__6000__auto__
(clojure.core/->
(f__5999__auto__)
(clojure.core.async.impl.ioc-macros/aset-all!
clojure.core.async.impl.ioc-macros/USER-START-IDX
c__5997__auto__
clojure.core.async.impl.ioc-macros/BINDINGS-IDX
captured-bindings__5998__auto__))]
(clojure.core.async.impl.ioc-macros/run-state-machine-wrapped
state__6000__auto__))))
c__5997__auto__)
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment