I have defined a protocol with  overload methods,and one has varargs:

(ns test)
(defprotocol Say
  (say [this a] [this a & b] "say hello"))
(defrecord Robot []
  Say
  (say [this a] (println (str "hello," a)))
  (say [this a & b] (println b)))

Then ,i new a robot and say something:
(let [ r (Robot.)]
  (say r "dennis"))

It worked and print "hello,dennis",but if i passed more than one
arguments,it failed:

(let [ r (Robot.)]
  (say r "dennis" "zhuang"))

and threw exception

java.lang.IllegalArgumentException: No single method: say of
interface: test.Say found for function: say of protocol: Say (test.clj:
9)

It seems that clojure find methods in protocol both by name and
arity,and in this situation it found more than one methods named
"say".

I don't know how to solve this problem,any suggestion? thanks a lot.

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