Hi Michael, See my response to Rich for a more complete example of what I am trying to do.
The unquoted let doesn't seem to work for me, e.g. (defmacro doit [thing] (let [evaled-thing thing] evaled-thing)) (macroexpand '(doit "foo")) -> "foo" (macroexpand-1 '(doit (.toUpperCase "foo"))) -> (.toUpperCase "foo") Even with the let, I sill don't get "FOO"... Stuart > Hi, > >> On Nov 7, 3:48 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: >>> The following macro in lancet defines an ant task. >>> >>> (defmacro define-ant-task [task-name] >>> `(def ~(symbol task-name) (create-ant-task ~task-name))) >>> >>> (At least) one of the following assumptions is wrong: >>> >>> (1) define-ant-task needs to be a macro so it can drop args into >>> def. >>> >>> (2) define-ant-task needs to be a function because task-name needs >>> to >>> be evaled on the way in. >>> >>> (3) using eval (which would solve the contradiction in 1 & 2) is >>> evil >>> and should be avoided. >>> > > As Rich pointed out, its unclear what you are trying to do, so I'm > making assumptions here, but this strikes me as similar to something I > encountered. I believe I got what I needed by wrapping an unquoted let > around the syntax-quote in order to force evaluation: > > (defmacro definte-ant-task [task-name] > (let [evaled-task-name task-name] ;; Force evaluation of task-name > `(def ~(symbol evaled-task-name) (create-ant-task ~evaled-task- > name)))) > > Using (eval) will work, but I agree, it feels wrong to use eval which > is why I sought after this solution here. > > /mike. > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---