3 ms·
Is there a good explanation somewhere of protocol internals -- what it looks like in the JVM when a protocol member is called/what bytecode is generated from a
by MBlume 13y ago
Is there a good explanation somewhere of protocol internals -- what it looks like in the JVM when a protocol member is called/what bytecode is generated from a protocol extension?
- wging 13y agoIf no one replies with a good answer, then your best bet might be https://github.com/clojure/clojure/tree/master/src https://github.com/clojure/clojure/tree/master/src . (I acknowledge this isn't really an answer to your question.) I will try to find the implementation of protocols in here for you... Edit: a start might be 'defprotocol' in https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_deftype.clj https://github.com/clojure/clojure/blob/master/src/clj/cloju...
- Skinney 13y agoIt depends. You implement a protocol while defining a record or type, so called inlined implementation, then it's the same as a Java class with a implemented interface. Clojure allows extending protocolls outside a record/type definition though. This allows you to extend protocolls to classes/types you haven't declared, like Clojure map. I'm uncertain how that is implemented though.