Skip to content

Commit d096eaa

Browse files
authored
Talk a bit more about defprotocol and methods (#226)
1 parent 2539fe5 commit d096eaa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.adoc

+17
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,8 @@ Follow ``clojure.core``'s example for idiomatic names like `pred` and `coll`.
10301030
** `expr` - an expression
10311031
** `body` - a macro body
10321032
** `binding` - a macro binding vector
1033+
* in methods (when specified in `defprotocol`, `deftype`, `defrecord`, `reify`, etc):
1034+
** `this` - for the first argument, indicating a reference to the object - or alternatively, a consistent name which describes the object
10331035

10341036
== Functions
10351037

@@ -2876,6 +2878,21 @@ the var as documentation.
28762878
(bar x))
28772879
----
28782880

2881+
[NOTE]
2882+
====
2883+
Place docstrings for `defprotocol` methods _after_ the argument vector:
2884+
2885+
[source,clojure]
2886+
----
2887+
(defprotocol MyProtocol
2888+
"MyProtocol docstring"
2889+
(foo [this x y z]
2890+
"foo docstring")
2891+
(bar [this]
2892+
"bar docstring"))
2893+
----
2894+
====
2895+
28792896
== Testing
28802897

28812898
=== Test Directory Structure [[test-directory-structure]]

0 commit comments

Comments
 (0)