>> My understanding is that invocation of protocol methods incurs about 30%
overhead due to the need to look up the appropriate function for the type.

I'd like to see some benchmarks on that. Protocols are actually quite fast,
and if you create the protocol first, then implement a type using that
protocol it should be as fast as any virtual method invocation in Java.

So I would first ask for proof of your first assertion.

Timothy

On Tue, Sep 8, 2015 at 6:11 PM, Gary Fredericks <fredericksg...@gmail.com>
wrote:

> I'm not an expert on this subject, but two thoughts come to mind:
>
>
>    1. the point of protocols is polymorphism, and if I understand you
>    correctly, the case you're describing is narrowed enough that it is
>    *not* polymorphic -- i.e., if the compiler can statically determine
>    what code to run, it's not polymorphic anymore, and you as the programmer
>    could have just called that code directly (though perhaps for some reason
>    you might not want to write it that way)
>    2. the previous point notwithstanding, I don't think static type
>    information is enough to pick an implementation, because you could still
>    conceivably encounter (at runtime) subclasses of the annotated type with
>    their own implementations, and have to check for that
>
>
> On Tuesday, September 8, 2015 at 3:59:41 PM UTC-5, Nathan Marz wrote:
>>
>> My understanding is that invocation of protocol methods incurs about 30%
>> overhead due to the need to look up the appropriate function for the type.
>> I also learned recently that Clojure does not use static type information
>> to do the lookup at compile-time and avoid the overhead. Given that Clojure
>> already does do some type analysis (to optimize Java method invocations),
>> why not do it for protocol invocation as well? Just trying to further my
>> understanding of the Clojure compiler.
>>
>>
>> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to