Oh, no...I understand now—it looks like I've incorrectly explained my problem.
I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2 3]). Clojure 1.0.0- user=> (use 'clojure.contrib.monads) nil user=> (defn a [& xs] (with-monad maybe-m (m-seq xs))) #'user/a user=> (a 1 2 3) (1 2 3) user=> (defmacro b [& xs] `(with-monad maybe-m (m-seq ~xs))) #'user/b user=> (b 1 2 3) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0) user=> (defmacro c [& xs] `(with-monad maybe-m (m-seq ~...@xs))) #'user/c user=> (c 1 2 3) java.lang.IllegalArgumentException: Wrong number of args passed to: monads$m-PLUS-m-seq-PLUS-m (NO_SOURCE_FILE:0) Trying both ~ and ~@ in this case gets me two kinds of errors. Thanks for your patient help. On May 12, 7:59 am, Konrad Hinsen <konrad.hin...@laposte.net> wrote: > On May 12, 2009, at 16:40, samppi wrote: > > > I thought that: > > `(with-monad maybe-m (m-seq ~xs))) > > > would insert [1 2 3] where ~xs would be, becoming the list: > > (with-monad maybe-m (m-seq [1 2 3])) > > It does, if you define your macro as > > (defmacro b [xs] > `(with-monad maybe-m (m-seq ~xs))) > > But your argument list was [& xs], which sets xs to the list of all > arguments given to the macro. > > Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---