On Sep 26, 7:35 am, Meikel Brandmeyer <m...@kotka.de> wrote: > The problem is, that you quote the symbol you inject into the inner > defmacro. Hence it does not get resolved. The solution in this case > seems to be to syntax-quote the symbol correctly before injection. > Replace the two ~'~ with ~~ and call the macro as (def-with-db-macro > with-foo `open-foo `close-foo). This correctly resolves the symbols in > the namespace calling def-with-db-macro and injects them into the with- > foo expansion. I haven't really tested this, but it seems to be > consistent with the macro machinery.
Thank you. That works. I had tried ~~ by itself, and it didn't fly. I didn't think to syntax-quote the symbol in its place of expansion. So referring back to http://paste.lisp.org/display/87734, the solution is: user> (defmacro make-myfoo [foo] `(defmacro ~'myfoo [s#] `(~~foo ~s#))) => #'user/make-myfoo user> (ns tmp) tmp> (user/make-myfoo `foo) => #'tmp/myfoo tmp> (macroexpand '(tmp/myfoo bar)) => (tmp/foo bar) As expected, in the tmp namespace. > This seems indeed useless at a first glance, but looking down the > cause trace usually shows the real problem. Full stack trace follows, although I still don't know what it means. No message. [Thrown class java.lang.ExceptionInInitializerError] Backtrace: 0: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 1: sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39) 2: sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27) 3: java.lang.reflect.Constructor.newInstance(Constructor.java:513) 4: java.lang.Class.newInstance0(Class.java:355) 5: java.lang.Class.newInstance(Class.java:308) 6: clojure.lang.Compiler$FnExpr.eval(Compiler.java:3428) 7: clojure.lang.Compiler.eval(Compiler.java:4531) 8: clojure.core$eval__3990.invoke(core.clj:1728) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---