secret
Created

first macro expand

  • Download Gist
pt1.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
(let [q '(a) y '(b) z '(c)]
(macroexpand-1
'(match [q y z]
[([_] :seq) _ _] 'a
[_ _ _] 'b)))
;; expands to
(try (clojure.core/cond (clojure.core/or (clojure.core/seq? q) (clojure.core/sequential? q))
(try (clojure.core/let [q_tail__3463 (clojure.core/rest q)]
(clojure.core/cond (clojure.core/empty? q_tail__3463)
(clojure.core/let [] (quote a))
:else (throw clojure.core.match/backtrack)))
(catch java.lang.Exception e__2590__auto__
(if (clojure.core/identical? e__2590__auto__ clojure.core.match/backtrack)
(do (throw clojure.core.match/backtrack))
(throw e__2590__auto__))))
:else (throw clojure.core.match/backtrack))
(catch java.lang.Exception e__2590__auto__
(if (clojure.core/identical? e__2590__auto__ clojure.core.match/backtrack)
(do (clojure.core/let [] (quote b)))
(throw e__2590__auto__))))
pt2.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(let [q '(a) y '(b) z '(c)]
(macroexpand-1
'(match [q (seq y) z]
[([_] :seq) _ _] 'a
[_ _ _] 'b)))
;; expands to
(clojure.core/let [q q ocr-3470 (seq y) z z]
(try (clojure.core/cond (clojure.core/or (clojure.core/seq? q) (clojure.core/sequential? q)) (clojure.core/let [q_tail__3472 q_tail__3472
q_head__3471 q_head__3471
ocr-3470 (seq y)
z z]
(try (clojure.core/let [q_tail__3472 (clojure.core/rest q)]
(clojure.core/cond (clojure.core/empty? q_tail__3472) (clojure.core/let [] (quote a))
:else (throw clojure.core.match/backtrack)))
(catch java.lang.Exception e__2590__auto__
(if (clojure.core/identical? e__2590__auto__ clojure.core.match/backtrack)
(do (throw clojure.core.match/backtrack))
(throw e__2590__auto__)))))
:else (throw clojure.core.match/backtrack))
(catch java.lang.Exception e__2590__auto__
(if (clojure.core/identical? e__2590__auto__ clojure.core.match/backtrack)
(do (clojure.core/let [] (quote b)))
(throw e__2590__auto__)))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.