<!-- 
RSS generated by JIRA (4.4#649-r158309) at Sat May 18 16:54:51 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/MATCH-42/MATCH-42.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>[MATCH-42] quoted symbols should be treated as literals</title>
                <link>http://dev.clojure.org/jira/browse/MATCH-42</link>
                <project id="10050" key="MATCH">core.match</project>
                        <description>&lt;p&gt;Reported on the Clojure mailing list:&lt;/p&gt;

&lt;p&gt;From: 	Alex Miller &amp;lt;alex@puredanger.com&amp;gt;&lt;br/&gt;
Subject: 	Symbol matching in core.match&lt;br/&gt;
Date: 	November 30, 2011 2:49:43 PM EST&lt;br/&gt;
To: 	Clojure &amp;lt;clojure@googlegroups.com&amp;gt;&lt;br/&gt;
Reply-To: 	clojure@googlegroups.com&lt;/p&gt;

&lt;p&gt;I&apos;ve been working with core.match some this week and finding it pretty&lt;br/&gt;
nice.  However, I have a common case (for me) that is not well handled&lt;br/&gt;
right now via core.match: matching symbols. Say that I wrote a match&lt;br/&gt;
like this:&lt;/p&gt;

&lt;p&gt;;; translate (+ x (+ y z)) to (+ x y z)&lt;br/&gt;
(let &lt;span class=&quot;error&quot;&gt;&amp;#91;e &amp;#39;(+ 1 (+ 2 3))&amp;#93;&lt;/span&gt;&lt;br/&gt;
 (match &lt;span class=&quot;error&quot;&gt;&amp;#91;e&amp;#93;&lt;/span&gt;&lt;br/&gt;
      [([+ x (&lt;span class=&quot;error&quot;&gt;&amp;#91;+ y z&amp;#93;&lt;/span&gt; :seq)] :seq)] (+ x y z)))&lt;/p&gt;

&lt;p&gt;You will see this error:&lt;br/&gt;
Pattern row 1: Pattern row reuses wildcards in [([+ x ([+ y&lt;br/&gt;
z] :seq)] :seq)].  The following wildcards are ambiguous: +.  There&apos;s&lt;br/&gt;
no guarantee that the matched values will be same.  Rename the&lt;br/&gt;
occurrences uniquely.&lt;/p&gt;

&lt;p&gt;Any symbol inside a pattern row is treated as a bind variable.  + is a&lt;br/&gt;
symbol.  You can achieve this with guards:&lt;/p&gt;

&lt;p&gt;(defn +? &lt;span class=&quot;error&quot;&gt;&amp;#91;s&amp;#93;&lt;/span&gt; (= &apos;+ s))&lt;/p&gt;

&lt;p&gt;(let &lt;span class=&quot;error&quot;&gt;&amp;#91;e &amp;#39;(+ 1 (+ 2 3))&amp;#93;&lt;/span&gt;&lt;br/&gt;
 (match &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;(+ 1 (+ 2 3))&amp;#93;&lt;/span&gt;&lt;br/&gt;
      [([(_o1 :when +?) x (&lt;span class=&quot;error&quot;&gt;&amp;#91;(_o2 :when +?) y z&amp;#93;&lt;/span&gt; :seq)] :seq)] (list&lt;br/&gt;
&apos;+ x y z)))&lt;/p&gt;

&lt;p&gt;but, yuck.  I can imagine using the reserved ()&apos;s with additional keys&lt;br/&gt;
(:symbol or :sym) to do symbol matching like (:symbol +) but also,&lt;br/&gt;
yuck.  The simplest idea I came up with was:&lt;/p&gt;

&lt;p&gt;(let &lt;span class=&quot;error&quot;&gt;&amp;#91;e &amp;#39;(+ 1 (+ 2 3))&amp;#93;&lt;/span&gt;&lt;br/&gt;
 (match &lt;span class=&quot;error&quot;&gt;&amp;#91;e&amp;#93;&lt;/span&gt;&lt;br/&gt;
      [([&apos;+ x (&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;+ y z&amp;#93;&lt;/span&gt; :seq)] :seq)] (&apos;+ x y z)))&lt;/p&gt;

&lt;p&gt;These come through as (quote x) although the error reporting goes a&lt;br/&gt;
little off the rails:&lt;br/&gt;
Pattern row 1: Pattern row reuses wildcards in [([(quote +) x ([(quote&lt;br/&gt;
+) y z] :seq)] :seq)].  The following wildcards are ambiguous: quote.&lt;br/&gt;
There&apos;s no guarantee that the matched values will be same.  Rename the&lt;br/&gt;
occurrences uniquely.&lt;/p&gt;

&lt;p&gt;However, that seems fixable and you could then use (quote x) as a&lt;br/&gt;
signal to do symbol matching.  If I can figure out what the hell I&apos;m&lt;br/&gt;
doing in core.match then I&apos;d be happy to work on a patch.&lt;/p&gt;</description>
                <environment></environment>
            <key id="15042">MATCH-42</key>
            <summary>quoted symbols should be treated as literals</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="3" iconUrl="http://dev.clojure.org/jira/images/icons/priority_major.gif">Major</priority>
                    <status id="5" iconUrl="http://dev.clojure.org/jira/images/icons/status_resolved.gif">Resolved</status>
                    <resolution id="1">Completed</resolution>
                                <assignee username="dnolen">David Nolen</assignee>
                                <reporter username="steveminer@gmail.com">Steve Miner</reporter>
                        <labels>
                    </labels>
                <created>Wed, 30 Nov 2011 16:41:54 -0600</created>
                <updated>Wed, 30 Nov 2011 18:52:38 -0600</updated>
                    <resolved>Wed, 30 Nov 2011 18:52:38 -0600</resolved>
                                                                    <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="27378" author="steveminer@gmail.com" created="Wed, 30 Nov 2011 16:56:16 -0600"  >&lt;p&gt;Skip anything that&apos;s quoted when looking for duplicate symbol names.  Added a test for the reported case.&lt;/p&gt;</comment>
                    <comment id="27379" author="steveminer@gmail.com" created="Wed, 30 Nov 2011 16:57:36 -0600"  >&lt;p&gt;patch attached&lt;/p&gt;</comment>
                    <comment id="27380" author="dnolen" created="Wed, 30 Nov 2011 18:52:38 -0600"  >&lt;p&gt;Fixed, &lt;a href=&quot;https://github.com/clojure/core.match/commit/6721be4fba74561038539e12667bc04cc5fc94cc&quot;&gt;https://github.com/clojure/core.match/commit/6721be4fba74561038539e12667bc04cc5fc94cc&lt;/a&gt;&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10728" name="match-42-quoted-symbol.patch" size="2549" author="steveminer@gmail.com" created="Wed, 30 Nov 2011 16:56:16 -0600" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                                                                            </customfields>
    </item>
</channel>
</rss>