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"))

Reference

http://clojure.org/datatypes


Clojure “protocol” and the “expression problem”

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

http://clojure.org/protocols

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: http://c2.com/cgi/wiki?ExpressionProblem but, better is to understand it as the general case of “Cross Cutting Concerns”, explained here: http://c2.com/cgi/wiki?CrossCuttingConcern

comment at https://plus.google.com/+XahLee/posts/1Nh68RParSL