<!-- 
RSS generated by JIRA (4.4#649-r158309) at Wed May 22 23:27:46 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/CLJ-1024/CLJ-1024.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CLJ-1024] Varargs protococol impls can be defined but not called</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-1024</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;The compiler accepts this:&lt;/p&gt;

&lt;p&gt;(deftype foo []&lt;br/&gt;
  clojure.lang.IFn&lt;br/&gt;
  (invoke &lt;span class=&quot;error&quot;&gt;&amp;#91;this &amp;amp; xs&amp;#93;&lt;/span&gt;))&lt;/p&gt;

&lt;p&gt;However calling ((foo.) :bar) will throw an AbstractMethodError. Wouldn&apos;t some checking be desirable?&lt;/p&gt;</description>
                <environment></environment>
            <key id="15574">CLJ-1024</key>
            <summary>Varargs protococol impls can be defined but not called</summary>
                <type id="4" iconUrl="http://dev.clojure.org/jira/images/icons/improvement.gif">Enhancement</type>
                                <priority id="4" iconUrl="http://dev.clojure.org/jira/images/icons/priority_minor.gif">Minor</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="2">Declined</resolution>
                                <assignee username="stu">Stuart Halloway</assignee>
                                <reporter username="vemv">V&#237;ctor M. Valenzuela</reporter>
                        <labels>
                        <label>patch</label>
                    </labels>
                <created>Tue, 10 Jul 2012 10:09:45 -0500</created>
                <updated>Thu, 14 Feb 2013 10:03:07 -0600</updated>
                    <resolved>Wed, 13 Feb 2013 21:22:42 -0600</resolved>
                            <version>Release 1.4</version>
                                <fixVersion>Release 1.5</fixVersion>
                                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="28971" author="tsdh" created="Wed, 11 Jul 2012 01:20:22 -0500"  >&lt;p&gt;First of all, clojure.lang.IFn is no protocol but an interface.  And it does not declare a&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;  public Object invoke(Object... obs)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;method.  It has an `invoke` method with 20 Object parameters followed by an Object... parameter, but to give an implementation for that, you have to specify every parameter separately, and the last Object... arg is just a normal argument that must be an Object[].  That&apos;s because Java-varags Type... parameters are just Java syntax sugar, but in the byte-code its simply a Type-array.&lt;/p&gt;

&lt;p&gt;What your example does is provide an `invoke` implementation for the 2-args version, where the first parameter happens to be named `&amp;amp;`, which has no special meaning here.  Take that example:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;(deftype MyFoo []
  clojure.lang.IFn
  (invoke [this &amp;amp; xs]
    [&amp;amp; xs]))

((MyFoo.) 1 2)
=&amp;gt; [1 2]
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But you are right in that `deftype`, `defrecord`, `defprotocol`, and `definferface` probably should error if user&apos;s seem to try to use varargs or destructuring.&lt;/p&gt;</comment>
                    <comment id="28972" author="vemv" created="Wed, 11 Jul 2012 01:55:22 -0500"  >&lt;p&gt;Cheers for a most clarifying response.&lt;/p&gt;

&lt;p&gt;The fact that the meaning of &amp;amp; gets &apos;subverted&apos; makes the issue only (slightly) worse, in my opinion.&lt;/p&gt;

&lt;p&gt;Just for the record, destructuring seems to work, at least for interface impls.&lt;/p&gt;</comment>
                    <comment id="28973" author="tsdh" created="Wed, 11 Jul 2012 02:42:33 -0500"  >&lt;p&gt;&amp;gt; The fact that the meaning of &amp;amp; gets &apos;subverted&apos; makes the issue only (slightly) worse, in my opinion.&lt;/p&gt;

&lt;p&gt;I agree.  I&apos;ll attach a patch which checks for those invalid usages soon.&lt;/p&gt;

&lt;p&gt;&amp;gt; Just for the record, destructuring seems to work, at least for interface impls.&lt;/p&gt;

&lt;p&gt;Could you please provide a complete example demonstrating your statement?&lt;/p&gt;

&lt;p&gt;I&apos;m rather sure that varargs and destructuring don&apos;t work for any of defprotocol, definterface, deftype, defrecord, and reify.  But you can use varargs and destructuring when providing dynamic implementations via `extend` (or `extend-protocol`, `extend-type`), because those impls are real functions in contrast to methods.&lt;/p&gt;</comment>
                    <comment id="28974" author="tsdh" created="Wed, 11 Jul 2012 02:43:31 -0500"  >&lt;p&gt;I attached a patch.  Here&apos;s the commit message:&lt;/p&gt;

&lt;p&gt;Check for invalid varags/destrucuring uses.&lt;/p&gt;

&lt;p&gt;Protocol, interface method declarations and implementations don&apos;t allow for&lt;br/&gt;
varags and destructuring support.  Currently, for example&lt;/p&gt;

&lt;p&gt;  (defprotocol FooBar&lt;br/&gt;
    (foo &lt;span class=&quot;error&quot;&gt;&amp;#91;this &amp;amp; more&amp;#93;&lt;/span&gt;))&lt;/p&gt;

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

&lt;p&gt;Similarly, providing method implementations via defrecord, deftype, and reify&lt;br/&gt;
don&apos;t allow for destructuring and varags (but dynamic extenions via extend do).&lt;/p&gt;

&lt;p&gt;So this patch makes defprotocol, definterface, defrecord, deftype, and reify&lt;br/&gt;
throw an IllegalArgumentException if any argument vector contains a&lt;br/&gt;
destructuring form or varargs argument.&lt;/p&gt;</comment>
                    <comment id="28975" author="vemv" created="Thu, 12 Jul 2012 03:13:58 -0500"  >&lt;p&gt;Glad you&apos;ve considered my request.&lt;/p&gt;

&lt;p&gt;As for destructuring, I was speaking after this example, which may or may not work like it looks like - I don&apos;t know.&lt;/p&gt;

&lt;p&gt;(deftype foo []&lt;br/&gt;
  clojure.lang.IFn&lt;br/&gt;
  (invoke [this &lt;span class=&quot;error&quot;&gt;&amp;#91;a b&amp;#93;&lt;/span&gt; c] (println a b c)))&lt;/p&gt;

&lt;p&gt;((foo.) &lt;span class=&quot;error&quot;&gt;&amp;#91;1 2&amp;#93;&lt;/span&gt; 3)&lt;/p&gt;</comment>
                    <comment id="28978" author="tsdh" created="Thu, 12 Jul 2012 08:22:47 -0500"  >&lt;p&gt;Indeed, descructuring seems to work for method implementations.  I&apos;ll adapt my patch...&lt;/p&gt;</comment>
                    <comment id="28979" author="tsdh" created="Thu, 12 Jul 2012 08:42:32 -0500"  >&lt;p&gt;Revamped patch.  Here&apos;s the commit message:&lt;/p&gt;

&lt;p&gt;Protocol, interface method declarations don&apos;t allow for varags and&lt;br/&gt;
destructuring support.  Currently, for example&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;  (defprotocol FooBar
    (foo [this &amp;amp; more]))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

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

&lt;p&gt;Similarly, providing method implementations via defrecord, deftype, and reify&lt;br/&gt;
don&apos;t allow for varags (but dynamic extenions via extend do).&lt;/p&gt;

&lt;p&gt;So this patch makes defprotocol and definterface throw an&lt;br/&gt;
IllegalArgumentException if a user tries to use varargs and destructuring in&lt;br/&gt;
method signatures.&lt;/p&gt;

&lt;p&gt;Similarly, defrecord, deftype, and reify throw an IllegalArgumentException if&lt;br/&gt;
any method implementation arglist contains a varargs argument.&lt;/p&gt;</comment>
                    <comment id="28983" author="jafingerhut" created="Thu, 12 Jul 2012 15:43:58 -0500"  >&lt;p&gt;Tassilo, with your patch 0001-&lt;a href=&quot;http://dev.clojure.org/jira/browse/CLJ-1024&quot; title=&quot;Varargs protococol impls can be defined but not called&quot;&gt;&lt;del&gt;CLJ-1024&lt;/del&gt;&lt;/a&gt;-Check-for-invalid-varags-destrucuring-uses.patch dated July 12, 2012, I get the following error message while testing, apparently because some metadata is missing on the new functions your patch adds to core:&lt;/p&gt;

&lt;p&gt;     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Testing clojure.test-clojure.metadata&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; &lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; FAIL in (public-vars-with-docstrings-have-added) (metadata.clj:45)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; expected: (= [] (remove (comp :added meta) public-vars-with-docstrin&lt;br/&gt;
gs-not-generated))&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt;   actual: (not (= [] (#&apos;clojure.core/throw-on-varargs-and-destr #&apos;cl&lt;br/&gt;
ojure.core/throw-on-varargs)))&lt;/p&gt;</comment>
                    <comment id="28984" author="tsdh" created="Fri, 13 Jul 2012 02:10:35 -0500"  >&lt;p&gt;Hi Andy, this updated patch declares the two new checking fns private which makes the tests pass again.&lt;/p&gt;

&lt;p&gt;Stupid mistake by me:  Of course, I&apos;ve tested the last version, too, but afterwards I decided it wouldn&apos;t be bad to add some docstrings, and of course, adding docstrings cannot break anything. &lt;img class=&quot;emoticon&quot; src=&quot;http://dev.clojure.org/jira/images/icons/emoticons/wink.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                    <comment id="29145" author="aaron" created="Tue, 14 Aug 2012 19:58:32 -0500"  >&lt;p&gt;Patch applies cleanly against 4004d267e124f12b65b0d7fb6522f32a75e3c4fb. Submitter confirmed as a CA signer. &lt;/p&gt;</comment>
                    <comment id="29146" author="aaron" created="Tue, 14 Aug 2012 20:02:17 -0500"  >&lt;p&gt;This looks ok to me, but it seems like a fair amount of duplication to accomplish the task. It seems like we should just be able to ask if it is ok to proceed, instead of having to pick which function needs to be called in what case.&lt;/p&gt;</comment>
                    <comment id="29160" author="tsdh" created="Wed, 15 Aug 2012 01:23:49 -0500"  >&lt;p&gt;Aaron, can you please elaborate?  I don&apos;t get what you mean with duplication and asking if it is ok to proceed.&lt;/p&gt;</comment>
                    <comment id="29311" author="tsdh" created="Fri, 31 Aug 2012 01:40:51 -0500"  >&lt;p&gt;Rebased to apply cleanly on master again.&lt;/p&gt;</comment>
                    <comment id="29313" author="vemv" created="Fri, 31 Aug 2012 07:11:55 -0500"  >&lt;p&gt;Pardon the silly contribution, but the added methods&apos; usage of double-negations (when-not ...) seems unnecessary.&lt;/p&gt;</comment>
                    <comment id="29314" author="tsdh" created="Fri, 31 Aug 2012 08:03:25 -0500"  >&lt;p&gt;Hi Victor, this revamped patch removes the double-negation and is more concise and clearer as a result.  So your comment wasn&apos;t as silly as you thought. &lt;img class=&quot;emoticon&quot; src=&quot;http://dev.clojure.org/jira/images/icons/emoticons/smile.gif&quot; height=&quot;20&quot; width=&quot;20&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                    <comment id="30594" author="tsdh" created="Thu, 14 Feb 2013 01:36:12 -0600"  >&lt;p&gt;Hey Stu, do you mind to explain why you&apos;ve declined the patch?&lt;/p&gt;</comment>
                    <comment id="30595" author="mnicky" created="Thu, 14 Feb 2013 08:52:03 -0600"  >&lt;p&gt;@Tassilo: &lt;a href=&quot;https://groups.google.com/forum/#!topic/clojure-dev/qjkW-cv8nog&quot;&gt;https://groups.google.com/forum/#!topic/clojure-dev/qjkW-cv8nog&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="30597" author="tsdh" created="Thu, 14 Feb 2013 10:03:07 -0600"  >&lt;p&gt;@Marek, Stu: Thanks, I&apos;ve left a reply there: &lt;a href=&quot;https://groups.google.com/d/msg/clojure-dev/qjkW-cv8nog/rMNFqbjNj-EJ&quot;&gt;https://groups.google.com/d/msg/clojure-dev/qjkW-cv8nog/rMNFqbjNj-EJ&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11463" name="0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch" size="3640" author="tsdh" created="Fri, 31 Aug 2012 08:03:25 -0500" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Approval</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10008">Not Approved</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                            <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Patch</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10001">Code</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                        </customfields>
    </item>
</channel>
</rss>