You need to name the protocol before the method implementations. That's why the "PersistentList cannot be cast to Symbol" message -- the compiler's expecting a protocol (or interface) symbol after [r].
And, as the examples on http://clojure.org/protocols show, you need to define the different arities of method-two separately: (defrecord record-two [r] protocol-two (method-two [x] (str x)) (method-two [x y] (str x ":" y))) Also note that all the examples use capitalized names for protocols and records. And I'm dubious about the hyphens in those names, too. I would have gone with ProtocolTwo (or Protocol2) and Record2. On Aug 4, 3:59 pm, James <jamesbo...@gmail.com> wrote: > I am having trouble getting syntax right when defining a protocol > function/method with multiple arities. When the defrecord is > evaluated I get: > > java.lang.ClassCastException: clojure.lang.PersistentList cannot be > cast to clojure.lang.Symbol > [Thrown class java.lang.RuntimeException] > > I have tried different variations, but cannot seem to get it right. > Please point out what I am doing wrong. > > The repl: > user> *clojure-version* > {:major 1, :minor 2, :incremental 0, :qualifier "RC1"} > user> (defprotocol protocol-two > (method-two [x] [x y])) > protocol-two > user> (defrecord record-two [r] > (method-two ([x] (str x)) > ([x y] (str x ":" y)))) > > Thanks for the help. -- 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