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")?

- Dmitry

On May 7, 1:42 pm, Jonathan Fischer Friberg <odysso...@gmail.com>
wrote:
> 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_d...
>
> 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/R...
> [2]https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/C...
>
> 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

Reply via email to