Macro-writing macro
Hi folksI have a couple of macros that looks like this:
(defmacro my-macro ((arg1 arg2) &body body)
(case *mode*
(:mode1 `(my-macro-implementation1 (,arg1 ,arg2) ,@body))
(:mode2 `(my-macro-implementation2 (,arg1 ,arg2) ,@body))))
I can then easily compile code using my-macro towards different implementations by setting (or letting) *mode* to :mode1 or :mode2.
But since I have a number of these macros, I thought it would be nice to generate them automatically, so that writing something like this:
(defmacro-mode my-macro ((arg1 arg2) &body body))
that expands into the above macro definition. But I can't figure out how to make this macro defmacro-mode, with an expansion that retains backquotes and commas in the right way (I feel like I have tried every possible combination of ` and , )
Any hints?
Regards
Erik