Details
-
Type:
Defect
-
Status:
Open
-
Priority:
Trivial
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Patch:Code
-
Approval:Incomplete
Description
The documentation for extend-type contains the following example:
(extend-type MyType
Countable
(cnt [c] ...)
Foo
(bar [x y] ...)
(baz ([x] ...) ([x y & zs] ...)))
However, [x y & zs] is not a valid parameter list for a protocol fn. The documentation should be appropriately amended.
This is very much related to http://dev.clojure.org/jira/browse/CLJ-1024.
NOTE: While varargs are not supported in protocol declarations, dynamic extension of a protocol via extend (extend-type, extend-protocol) does allow for varargs and also destructuring, cause the method impls are actually normal clojure functions.
So if a Foo protocol declares a (foo [this a b c]) method, you can extend/extend-type/extend-protocol it dynamically using (foo [this & more] (do-magick)) where `a b c` are conflated into the `more` parameter.
However, that doesn't work for method implementations defined by deftype, defrecord, and reify.
So with respect to the facts, the example in the docstring is actually correct, so I'm not sure if it should be changed. However, what's supported in which cases should be documented better as it is right now.