Clojure Tutorial: protocol

By Xah Lee. Date:

This page is WORK IN PROGRESS.

clojure protocol

“protocol” is a Clojure data type, kinda like a mix of Java abstract class and Java Interface .

protocol is a set of methods, without implementation.

;; defining a protocol
(defprotocol pr3
  "my protocol, yay"
  (m1 [x] "a method.")
  (m2 ([x] [a b]) "another method"))


Clojure “protocol” and the “expression problem”

Clojure's “protocol” (expression problem) is roughly a layer of mix of java abstract class and class interface.

The “expression problem” isn't really a problem in computer science. It is a problem as in: “Houston, we have a problem.”

I'll have more detailed article later. For now, the best place to see is:

the “Expression Problem” is best explained here: but, better is to understand it as the general case of “Cross Cutting Concerns”, explained here:

comment at