Welcome! Please see the About page for a little more info on how this works.

0 votes
in Errors by

I tried to use & in the signature for a method in defprotocol. Apparently (see below), this is compiled so that & becomes a simple parameter name, and there is no special handling for variable number of parameters. I think the use of & in a protocol signature ought to be detected and immediately cause an exception (I also think this restriction on the signatures ought to be documented; I couldn't find it specified in the current documentation, though of course it is implied (as I later realized) by the fact that defprotocol creates a Java interface).

user=> (defprotocol Applier (app (link: this f & args)))
user=> (deftype A (link: ) Applier (app (link: _ f & args) (prn f & args) (apply f args)))
user=> (app (A.) + 1 2)

<core$PLUS clojure.core$PLUS@5d9d0d20> 1 2

IllegalArgumentException Don't know how to create ISeq from: java.lang.Long
clojure.lang.RT.seqFrom (RT.java:487)

16 Answers

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-888 (reported by glchapman)