You are using macroexpand wrong. Don't eval anything when you are
macroexpanding - the point is to see what code will be executed.

The issue Kevin is bringing to your attention is evident in the first
code snippet you gave:

... :content ({:tag :profileDetail, :name
 "first.name", :value "stub", :content nil}
{:tag :profileDetail, :name "
last.name", :value "stub", :content nil} ...)

You intend :content to be a key whose value is a list of maps; but the
reader evals the forms it sees, and lists are function calls. So, it
calls the first map as a function, with the next three as arguments.
Maps don't like that many arguments, and you get the error you saw.

On Apr 25, 9:46 pm, Timothy Washington <twash...@gmail.com> wrote:
> Oh sorry, were the colors off? Let's try this.
>
> The map was actually unquoted. 'etal' (which was null) was unquote-spliced.
> I excluded it for clarity:
> *   user=> `(commands/add ~processed) *
> *   result=> (<my-function> <my-map>) ;; ** first in this list is a function
> *
>
> Now, if I try to eval that, I get the said error.
> *   user=> (eval `(commands/add ~processed))*
> *   result=> java.lang.IllegalArgumentException: ...*
>
> And I had tried macroexpand (here and in the containing function), and got
> the same error:
> *   user=> (macroexpand (eval `(commands/add ~processed)))*
> *   result=> java.lang.IllegalArgumentException: ...*
>
> You're right that the repl is using the map as a function. But I don't
> understand why when 'commands/add' function was the first thing in the
> return list. And macroexpand is yielding the same error . This is what had
> me so perplexed. Hopefully this reads a bit better.
>
> Thanks
> Tim
>
>
>
>
>
>
>
> On Tue, Apr 26, 2011 at 12:00 AM, Kevin Downey <redc...@gmail.com> wrote:
> > sorry I cannot read your email
>
> > On Mon, Apr 25, 2011 at 8:24 PM, Timothy Washington <twash...@gmail.com>
> > wrote:
> > > Hey Kevin, thanks for getting back to me.
>
> > > The splice is 'etal' (which is null). I should have excluded it for
> > > clarity. What you're actually seeing is the map being unquoted:
> > > user=> `(commands/add ~processed ~@etal)
> > > (commands/add {:tag :user, :username "stub" ... }) ;; 'etal' does not
> > show
> > > up in what gets evaluated - ** first in this list is a function
>
> > > Now, if I try to eval that, I get the said error.
> > > user=> (eval `(commands/add ~processed))
> > > java.lang.IllegalArgumentException: Wrong number of args (3) passed to:
> > > PersistentArrayMap (NO_SOURCE_FILE:324)
>
> > > And I had tried macroexpand (here and in the containing function), and
> > got
> > > the same error:
> > > user=> (macroexpand (eval `(commands/add ~processed)))
> > > java.lang.IllegalArgumentException: Wrong number of args (3) passed to:
> > > PersistentArrayMap (NO_SOURCE_FILE:324)
>
> > > You're right that the repl is using the map as a function. But I don't
> > > understand why when 'commands/add' function was the first thing in the
> > > return list. And macroexpand is yielding the same error . This is what
> > had
> > > me so perplexed. Thanks again for the feedback. It's something small that
> > > I'm missing.
> > > Tim
>
> > > On Mon, Apr 25, 2011 at 10:40 PM, Kevin Downey <redc...@gmail.com>
> > wrote:
>
> > >> your map is being spliced in to the output, but your output contains
> > >> lists (...) which are interpreted as functions, and the first thing in
> > >> the list is a map, makes take 1-2 args, your list forms with maps as
> > >> the operator have more that 2 args. please use macroexpand.
>
> > >> On Mon, Apr 25, 2011 at 7:29 PM, Timothy Washington <twash...@gmail.com
>
> > >> wrote:
> > >> > Hey all,
>
> > > --
> > > 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
>
> > --
> > And what is good, Phaedrus,
> > And what is not good—
> > Need we ask anyone to tell us these things?
>
> > --
> > 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

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

Reply via email to