I'm working on a project where I want to use clojure macros in part of my config file that I eval at runtime. However, I'm getting an "Unable to resolve symbol" exception. So I made a test case to reproduce it below:
(ns test.core (:gen-class)) (defmacro make-list [& body] `(list ~@body)) (defn stuff[] (prn (eval (read-string "(make-list 1 2 3)")))) (defn -main [& args] (stuff)) (-main) When I run this file through the clojure interpreter I get the output "(1 2 3)" from the -main call. Now if I do 'lein run' with my 'main' namespace defined as test.core, I get this output: (1 2 3) Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: make-list in this context, compiling:(NO_SOURCE_PATH: 1) at clojure.lang.Compiler.analyze(Compiler.java:6235) at clojure.lang.Compiler.analyze(Compiler.java:6177) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3452) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411) at clojure.lang.Compiler.analyze(Compiler.java:6216) at clojure.lang.Compiler.analyze(Compiler.java:6177) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407) at clojure.lang.Compiler.analyze(Compiler.java:6216) at clojure.lang.Compiler.eval(Compiler.java:6462) at clojure.lang.Compiler.eval(Compiler.java:6431) at clojure.core$eval.invoke(core.clj:2795) at test.core$stuff.invoke(core.clj:7) at test.core$_main.doInvoke(core.clj:9) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.Var.invoke(Var.java:397) at user$eval46.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:6465) at clojure.lang.Compiler.eval(Compiler.java:6455) at clojure.lang.Compiler.eval(Compiler.java:6431) at clojure.core$eval.invoke(core.clj:2795) at clojure.main$eval_opt.invoke(main.clj:296) at clojure.main$initialize.invoke(main.clj:315) at clojure.main$null_opt.invoke(main.clj:348) at clojure.main$main.doInvoke(main.clj:426) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:405) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:518) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Unable to resolve symbol: make- list in this context at clojure.lang.Util.runtimeException(Util.java:156) at clojure.lang.Compiler.resolveIn(Compiler.java:6720) at clojure.lang.Compiler.resolve(Compiler.java:6664) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6625) at clojure.lang.Compiler.analyze(Compiler.java:6198) ... 31 more So first I get the "(1 2 3)" output from clojure calling -main when it reads the file, but it seems like when lein calls -main it can't resolve the symbol. Is this a limitation of java since this is at runtime and macros have to be expanded at read-time? Or is this a bug? -- 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