Protocol callsites are already optimized in clojure.
Here's the emitted bytecode for a protocol invocation:
0: aload_0
1: aconst_null
2: astore_0
3: dup
4: invokestatic #36 // Method
clojure/lang/Util.classOf:(Ljava/lang/Object;)Ljava
>> 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
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