I'm learning macros, and I've figured something out that works for what I want to do but looks awfully weird. Is this a hacky mess because I don't know the clean way to do it or an idiom I just need to get used to?
I want a macro expansion to define some functions in the namespace of the "caller." I think I need syntax-quoting because I need to drop some arguments in place, but since syntax-quoting namespace-qualifies symbols with the namespace of the macro, I'm using a let to also drop in the symbols that I don't want namespace-qualified. Here's a simple example that shows what I'm talking about: (ns foo) (defmacro defthing [s] (let [thing-name 'thing] `(def ~thing-name (format "the %s thing" ~s)))) (ns bar) (foo/defthing "Bar") (ns user) (foo/defthing "User") thing => "the User thing" bar/thing => "the Bar thing" So this works, and that's great, but that let is pretty gross. Am I missing a cleaner way? Thanks. -hume. -- http://elhumidor.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---