On 11.05.2009, at 23:17, samppi wrote:

> user=> (defmacro b [& xs]
> `(with-monad maybe-m (m-seq ~xs)))
> #'user/b
> user=> (b [1 2 3])
> java.lang.IllegalArgumentException: Wrong number of args passed to:
> LazilyPersistentVector (NO_SOURCE_FILE:0)
>
> So there's something wrong with how I'm phrasing the macro. But I
> can't figure out what's going on.

The best way to find out is macroexpand-1:

(macroexpand-1 '(b [1 2 3]))
-> (clojure.contrib.monads/with-monad clojure.contrib.monads/maybe-m  
(clojure.contrib.monads/m-seq ([1 2 3])))

So what you are feeding to m-seq is a list containing a vector. The  
solution is:

(defmacro b [xs]
   `(with-monad maybe-m (m-seq ~xs)))
(b [1 2 3])
-> (1 2 3)

Or, if you prefer:

(defmacro b [& xs]
   `(with-monad maybe-m (m-seq ~...@xs)))

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to