Forbid varargs defprotocol/definterface method declarations because those cannot be defined anyway


Protocol, interface method declarations don't allow for varags. Currently, for example

compiles just fine, and & is interpreted as a usual argument that happens to be
named & without special meaning. But clearly, the user wanted to specify a
varags parameter here. The same applies to definterface.

Similarly, providing method implementations via defrecord, deftype, and reify
don't allow for varags (but dynamic extensions via extend do).

So this patch makes defprotocol and definterface throw an
IllegalArgumentException if a user tries to use varargs in method signatures.

Similarly, defrecord, deftype, and reify throw an IllegalArgumentException if
any method implementation arglist contains a varargs argument.

This patch is a cut-down variant of my patch to
which has been reverted shortly before Clojure 1.5 was released. The CLJ-1024 patch
was the same as this one, but it has also forbidden destructuring in defprotocol and
definterface. This was a bit too much, because although destructuring has no
semantic meaning with method declarations, it still can serve a documentation purpose.

This has been discussed on the list:




Tassilo Horn
March 31, 2013, 11:17 AM

New version of the patch that mentions both method name and argument vector, and uses ex-info as Stu suggested.

Andy Fingerhut
April 5, 2013, 1:24 AM

Presumuptuously changing Approval from Incomplete back to None, since the reason for marking it Incomplete seems to have been addressed with a new patch.

Andy Fingerhut
October 26, 2013, 12:29 AM

I have not investigated the reason yet, but patch 0001-Protocol-interface-method-declarations-don-t-allow-f.patch no longer applies cleanly after the latest commits to Clojure master on Oct 25 2013.

Tassilo Horn
October 28, 2013, 8:18 AM

I'm closing this issue in favor of which is about the very same issue and contains a more recent patch that also contains test cases.

Nicola Mometto
June 5, 2015, 3:56 PM

Ticket was marked as a duplicate and resolved but not closed. I'm closing it.



Stuart Halloway


Tassilo Horn