I am fairly new to CL and have problems with nested backquotes and unquotes.
I am trying something like currying or "partial" (in Clojure) does for functions but here with macros - I want to partially bind macros with parameters in a MACROLET-environment:
Code: Select all
(defmacro with-partial-macro (name macro list-of-args &body body)
`(macrolet ((,name (&rest more-args)
`(,,macro ,,@list-of-args ,@more-args)))
,@body))
(defmacro testmacro (&rest args)
`(+ ,@args))
Code: Select all
TOOLS> (macroexpand-1 '(with-partial-macro partial-plus testmacro (1 2 3)
(partial-plus 4 5 6)))
-->
(MACROLET ((PARTIAL-PLUS (&REST MORE-ARGS)
`(,TESTMACRO ,1 ,2 ,3 ,@MORE-ARGS)))
(PARTIAL-PLUS 4 5 6))
This
Code: Select all
`(,TESTMACRO ,1 ,2 ,3 ,@MORE-ARGS)))
Code: Select all
`(TESTMACRO 1 2 3 ,@MORE-ARGS)))