To elaborate on Nicola's correct answer, when -main is run from outside its namespace, the binding of mx comes from the current environment (which doesn't see a macro, and likely has no binding for mx). If you use ` in -main, the currently visible binding is properly namespace qualified so that it expands when called from outside the namespace.
On Thu, Feb 15, 2018, 03:12 Nicola Mometto <brobro...@gmail.com> wrote: > Use ` instead of ' > > > On 15 Feb 2018, at 08:45, 'Burt' via Clojure <clojure@googlegroups.com> > wrote: > > Here is something strange, and I don't see why! > Can anybody help? > > This is the code in m.clj > > (ns m > (:gen-class)) > > (defmacro mx > [x] > (list 'y)) > > (defn -main [] > (println (macroexpand-1 '(mx P))) > (println (macroexpand-1 '(and P Q)))) > > > 1 When i load the namespace into a REPL and invoke (-main) > > the result is (as expected): > > > (y) > (clojure.core/let [and__5236__auto__ P] (if and__5236__auto__ > (clojure.core/and Q) and__5236__auto__)) > => nil > > > 2 When I make an uberjar with leiningen (in IntelliJ with cursive) and run > the jar > > the result is (not as expected): > > > (mx P) > (clojure.core/let [and__5236__auto__ P] (if and__5236__auto__ > (clojure.core/and Q) and__5236__auto__)) > > > In the second case the macro mx is not expanded and I have no idea why this > is the case. > > > Kind regards, > > Burt > > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.