Hi!
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:
This
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:
(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))
Here is the expansion: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))
The double unquoting with ,, and ,,@ does not work the way I would like:This
`(,TESTMACRO ,1 ,2 ,3 ,@MORE-ARGS)))
should be
`(TESTMACRO 1 2 3 ,@MORE-ARGS)))
Perhaps someone can help me?