(a) There's no reason for this to be a macro at all: you don't need to prevent evaluation of anything, and you don't need to transform any syntax. Just write a function: (defn asdf [& {:keys [a]}] (println (comp (partial + 1) a)))
(b) To make this a macro, just be more careful about what you evaluate at runtime vs compile-time: (defmacro asdf [& {:keys [a]}] `(println (comp (partial + 1) ~a))) On Sep 26, 2:14 am, "sailormoo...@gmail.com" <sailormoo...@gmail.com> wrote: > Hi : > > I would like to create a macro as follows. > Note : the prinln function actually is something more sophisticated, > but I would like to evaluate the composition of one predefined function and > the other from the input argument. > > And I got some errors, why? > Thanks > > user=> (defmacro asdf [& {:keys [a]}] > `(println ~(comp (partial + 1) a))) > #'user/asdf > user=> (asdf :a (partial * 2)) > IllegalArgumentException No matching ctor found for class > clojure.core$comp$fn__ > 4034 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) -- 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