Chapter 7Protocols and Datatypes
Abstractions lay at the foundation of reusable code. The Clojure language itself has abstractions for sequences, collections, and callability. Traditionally, these abstractions were described with Java interfaces and implemented using Java classes. In the beginning, Clojure provided proxy and gen-class, removing the need to drop all the way to Java to achieve this, but that changed with the introduction of protocols.
-
Protocols provide an alternative to Java interfaces for high-performance polymorphic method dispatch.
-
Datatypes provide an alternative to Java classes for creating implementations of abstractions defined with either protocols or interfaces.
Protocols and datatypes provide a high-performance, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access