Skip to content

@lynaghk /project.clj secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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)
@lynaghk
Owner

So here's the story:

Running lein uberjar on source containing the offending function, geo->svg, results in a non-working application---the match always drops to the :else clause.
However, if match is manually macroexpanded in the repl and the results pasted in, then the JAR works just fine.

@lynaghk
Owner

Updated to minimal example. Output:

kevin@sigma:~/gist-35fa11df$ java -jar match-jar-1.0.0-SNAPSHOT-standalone.jar 
A
no matches = (
no matches = (

A
B
no matches = (

This is with

Leiningen 1.7.0 on Java 1.7.0_03 Java HotSpot(TM) 64-Bit Server VM

and

cake 0.6.3
@swannodette

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
Something went wrong with that request. Please try again.