I wrote that up quickly without thinking much about it.  Yes, the
invocation is definitely a macro and not a function.  Still, I think
it would be helpful to see the symbol's value and, if possible, the
macro's arity.

On Feb 27, 1:13 pm, Ken Wesson <kwess...@gmail.com> wrote:
> On Sun, Feb 27, 2011 at 2:10 PM, Ken Wesson <kwess...@gmail.com> wrote:
> > On Sat, Feb 26, 2011 at 8:14 PM, Mark <markaddle...@gmail.com> wrote:
> >> I get this:
> >> #<CompilerException java.lang.IllegalArgumentException: Wrong number
> >> of args (3) passed to: Symbol (C:\Users\addma03\workspace\test\src\main
> >> \clojure:1)>
>
> >> A few suggestions:
> >> 1)  An improved line number
> >> 2) I'd like to see the value of the Symbol
> >> 3) I'd like to see the three args applies to the symbol and, if the
> >> symbol resolves to a function, I'd like to see the arity of the
> >> function.
>
> >> Something like:
> >> Wrong number of args (3) passed to Symbol 'some-fn' which expects
> >> arity 2
>
> > This is interesting. I just checked with my copy of 1.2 and it seems
> > you can indeed call a symbol as a function. It appears to try to look
> > itself up in its first argument, the same as a keyword, and if not
> > found or the first argument is not a map returns the (optional) second
> > argument:
>
> > user=> ('+ {'+ 3 '* 4} 42)
> > 3
> > user=> ('+ {'- 3 '* 4} 42)
> > 42
>
> > Of course this is rather icky to use because of the need to quote the 
> > symbols.
>
> > So, the arity expected by a function like + ends up irrelevant. If you
> > invoke something on '+ it wants either one or two arguments.
>
> > If you're seeing this error you probably have a buggy macro that's not
> > unquoting something as many times as it should be. Quoting-depth
> > errors (other than forgetting to unquote something at all) seem to be
> > most common when writing macros that emit other macros, and ending up
> > with nested syntax-quoted expressions, doubled-up ~~@foo type
> > unquotings, and things like `(quote ~foo) in helper functions.
>
> > If the error points to a macro invocation I'd suggest inspecting the
> > output of (macroexpand-1 '(the-problem-invocation)) and seeing what
> > you get. If the output contains quoted symbols in operator position
> > that clearly are meant to be just normal calls to functions then
> > you've at least determined that the problem is caused by the macro.
> > Though it could be the case that your arguments to the macro violate
> > its preconditions. If it's not your own macro, check its
> > documentation. If it is it has a bug since it's not doing what you
> > want it to do and it's yours. If it's not it may or may not have a
> > bug.
>
> Addendum: the most likely macro *argument* error to cause this is
> quoting a function name macro argument that you shouldn't be quoting,
> e.g. (the-macro 'my-func ...) instead of (the-macro my-func ...). The
> macro just plops (quote my-func) wherever it should put my-func and
> boom!

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