(I repost this message because the original post I made yesterday seems to have been rejected by googlegroups -- I have not received it and it is not available online. Sorry if this will result in a double post for some users.)
Hi all, I'm writing a Scala library (currently alpha) to simplify the use of Datomic (http://www.datomic.com) from Scala: https://github.com/fbellomi/**datomic-scala<https://github.com/fbellomi/datomic-scala> I would like to make use of Scala compile-time macros in order to statically type-check Datomic queries against a live database schema. I need to call Datomic API from within the Scala compiler's macro expansion stage, but it turns out that Clojure runtime fails to initialize within that stage. A simple evaluation such as: clojure.lang.RT.T works fine from Scala's REPL, but fails from within Scala compiler, with the following exception error: exception during macro expansion: java.lang.**IllegalStateException: Attempting to call unbound fn: #'clojure.core/refer at clojure.lang.Var$Unbound.**throwArity(Var.java:43) at clojure.lang.AFn.invoke(AFn.**java:39) at clojure.lang.Var.invoke(Var.**java:415) at clojure.lang.RT.doInit(RT.**java:449) at clojure.lang.RT.<clinit>(RT.**java:318) at .foo_impl(<console>:8) Not only the classpath, but also the thread context ClassLoader is the same in both cases. I posted the details here: https://groups.google.com/forum/?hl=en&fromgroups=#!topic/scala-user/Bh_YmI6e-wY One could argue that this seems to be more of a Scala issue, but I did a search and it turns out that there are other similar situations where the Clojure runtime fails to initialize with the same error: - from within a Nutch plugin: https://groups.google.com/forum/?hl=en&fromgroups=#!searchin/clojure/nutch$20plugin/clojure/Fbqrk1T8SRg/CbQDd1yBvjYJ - trying to deploy an EJB https://groups.google.com/forum/?hl=en&fromgroups=#!searchin/clojure/ejb/clojure/FFe7Pf9TfXc/rxmYq6IoIjMJ - naming your project "clojure" in lein http://osdir.com/ml/java-clojure-user/2012-04/msg00913.html To further investigate my case, I tried to force the startup from core.clj rather than from the precompiled classes. Also in this case, the same call from the Scala repl works fine, whereas the call from within the Scala macro expansion fails, with this: ava.lang.ClassCastException: clojure.core$fn cannot be cast to clojure.lang.IFn, compiling:(clojure/core.clj:55) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.analyze(Compiler.java:6223) at clojure.lang.Compiler.eval(Compiler.java:6515) at clojure.lang.Compiler.load(Compiler.java:6952) at clojure.lang.RT.loadResourceScript(RT.java:359) at clojure.lang.RT.loadResourceScript(RT.java:350) at clojure.lang.RT.load(RT.java:429) at clojure.lang.RT.load(RT.java:400) at clojure.lang.RT.doInit(RT.java:436) at clojure.lang.RT.<clinit>(RT.java:318) at .foo_impl(<console>:8) Caused by: java.lang.ClassCastException: clojure.core$fn cannot be cast to clojure.lang.IFn at clojure.lang.Var.fn(Var.java:392) at clojure.lang.Var.invoke(Var.java:431) at clojure.lang.AFn.applyToHelper(AFn.java:178) at clojure.lang.Var.applyTo(Var.java:532) at clojure.lang.Compiler.macroexpand1(Compiler.java:6366) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6441) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.analyze(Compiler.java:6223) at clojure.lang.Compiler.eval(Compiler.java:6515) at clojure.lang.Compiler.load(Compiler.java:6952) at clojure.lang.RT.loadResourceScript(RT.java:359) at clojure.lang.RT.loadResourceScript(RT.java:350) at clojure.lang.RT.load(RT.java:429) at clojure.lang.RT.load(RT.java:400) at clojure.lang.RT.doInit(RT.java:436) at clojure.lang.RT.<clinit>(RT.java:318) Thanks in advance for any help or pointer. Francesco -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en