This. Macros, unless you do some gymnastics, always generate fully- qualified names, which is a Good Thing. You can't bind qnames, in let or function arguments or anywhere else. But clojure provides you with a very useful var# syntax: this creates a new symbol which is guaranteed to be unique, and lets you refer to it by that name throughout the macro expansion. Here's a basic example:
(defmacro square [x] `(let [val# ~x] (* val# val#))) (macroexpand '(square 3)) ==> (let* [val__4209__auto__ 3] (clojure.core/* val__4209__auto__ val__4209__auto__)) On Nov 8, 7:10 am, Sunil S Nandihalli <sunil.nandiha...@gmail.com> wrote: > use session# instead of session .. I think that should work.. try it.. > > On Mon, Nov 8, 2010 at 8:32 PM, Miki <miki.teb...@gmail.com> wrote: > > Greetings, > > > I need some help with the 1'st macro I'm writing. > > I have many tests in the format > > > (deftest user-test > > (let [session (test-session :authorization)] > > (dispatcher "USER bugs" session) > > (is (= (:user @session) "bugs")) > > (is (= (get-one session) "+OK Hello bugs\n")))) > > > I've tried writing > > > (defmacro def-dispatcher-test [test-name state command & body] > > `(deftest ~test-name > > (let [session (test-session ~state)] > > (dispatcher ~command session) > > ~...@body))) > > > (def-dispatcher-test user-test :authorization "USER bugs" > > (is (= (:user @session) "bugs")) > > (is (= (get-one session) "+OK Hello bugs\n"))) > > > But I get the following error; > > > Caused by: java.lang.Exception: Can't let qualified name: pop32imap- > > test/session > > > I probably need to add some magic to the session expansion, but can't > > figure out what. > > > Thanks, > > -- > > Miki > > > -- > > 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<clojure%2bunsubscr...@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 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