On May 7, 11:28 pm, Dmitry Kakurin <dmitry.kaku...@gmail.com> wrote: > Let me rephrase my question to avoid unfortunate confusion with > standard "count" function: > Suppose I have extended my own IMyCountable protocol with a > single "mycount" method to String class. What happens when I call > (mycount > "some string")? [snip..]
This is my (i.e. non authoritative) guess. defprotocol generates an interface and dispatch functions for each of your protocol functions. The dispatch function is a level of indirection between your (mycount "some string") and the actual call of your implementation. When you extend the protocol to reach a type there are two cases 1) if you are simultaneously defining a new type and extending the protocol, the underlying new class of the type can directly implement the interface. The dispatch function simply calls the appropriate interface method directly on the object (first argument of the protocol function). 2) (your case) you are extending an existing type. This dispatch function is changed to take account if this new case (I believe the dispatch is a switch on the class of the first argument to the protocol function). I could be wrong, but I don't think it is that far. Kind Regards, - Karl -- 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