See: http://clojure.org/protocols "defprotocol will automatically generate a corresponding interface" Although it is not true that a protocol is equivalent to an interface.
For deep "under the hood" you can check out the source: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj#L521 As for your specific case: clojure.core/count uses clojure.lang.RT/count [1] This function goes through some type checks, the first one being if the type implements clojure.lang.Counted [2] and if it is, calls the count function implemented in that type. [1] https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L505 [2] https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Counted.java On Sat, May 7, 2011 at 10:00 PM, Dmitry Kakurin <dmitry.kaku...@gmail.com>wrote: > Is there a document describing internal implementation of Clojure > protocols? > I.e. what is happening "under the hood"? > To be specific suppose I have extended ICountable protocol with a > single "count" method to String class. What happens when I call (count > "some string")? > At what point dynamic dispatch happens and what underlying JVM > mechanism is used? > > - Dmitry > > -- > 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