Very well, something along these lines would be my guess too.
But that would mean that in case 2 protocols are no faster 
than multimethods.
And I've got an impression that protocols are described to be as fast as 
interface dispatch (callvirt).
So either my impression is wrong (which is totally possible) or there is 
some clever trick available on JVM to do case 2 below faster.
That's why I'm asking.

Also for case 1 your description implies that even for your own types there 
is a performance penalty for extending interfaces *after* type definition.
I'm curious if that's the case as well.

- Dmitry

On Saturday, May 7, 2011 11:29:16 PM UTC-7, Krukow wrote:

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

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