Skip to content

Instantly share code, notes, and snippets.

@lynaghk
Created February 24, 2012 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynaghk/35fa11df7d7516abff50 to your computer and use it in GitHub Desktop.
Save lynaghk/35fa11df7d7516abff50 to your computer and use it in GitHub Desktop.
core.match + JAR troubles
(ns core
(:use [clojure.core.match :only [match]])
(:gen-class))
(defn m1 [x]
(match [x]
[{:type "A"}] "A"
[{:type "B"}] "B"
:else "no matches = ("))
(defn m2 [x]
;;manually macroexpanded version of form in m1.
(try (clojure.core/cond (clojure.core/or (clojure.core/instance? clojure.lang.ILookup x) (clojure.core/satisfies? clojure.core.match/IMatchLookup x)) (try (clojure.core/let [x_type__2413 (clojure.core.match/val-at* x :type :clojure.core.match/not-found)] (clojure.core/cond (clojure.core/= x_type__2413 "A") "A" (clojure.core/= x_type__2413 "B") "B" :else (throw clojure.core.match/backtrack))) (catch java.lang.Exception e__594__auto__ (if (clojure.core/identical? e__594__auto__ clojure.core.match/backtrack) (do (throw clojure.core.match/backtrack)) (throw e__594__auto__)))) :else (throw clojure.core.match/backtrack)) (catch java.lang.Exception e__594__auto__ (if (clojure.core/identical? e__594__auto__ clojure.core.match/backtrack) (do (clojure.core/let [] "no matches = (")) (throw e__594__auto__)))))
(defn -main [& args]
(println (m1 {:type "A"}))
(println (m1 {:type "B"}))
(println (m1 {:type "none"}))
(print "\n")
(println (m2 {:type "A"}))
(println (m2 {:type "B"}))
(println (m2 {:type "none"})))
(defproject match-jar "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/core.match "0.2.0-alpha9"]]
:main core)
@swannodette
Copy link

Thanks for taking the time to put this minimal example together, I'm finally looking into the AOT issues and this is super helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment