As define in the documentation,
A protocol is a named set of named methods and their signatures, defined using defprotocol.
(defprotocol IFoo "IFoo doc" (fooA [this] "fooA doc") (fooB [this] [this a] "fooB doc"))
You can add some documentation to the protocol and to each methods it contains. You don’t need to provide methods’ implemantation. After created your protocol, you can use
reify for defining its methods implementation.
In our case, we will use
deftype because the major difference between
defrecord is that
deftype provides just the functionalities implemented by the user, contrary to
Let’s see the below example:
OK! If you are like me, you give me that the generated code is difficult to understand! So, let’s simplify it: