<!-- 
RSS generated by JIRA (4.4#649-r158309) at Sun May 19 18:39:56 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-207/CLJ-207.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-207] for macro does not allow :let clause in first position</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-207</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;I like to try and keep my level of nesting under control, and this&lt;br/&gt;
often involves hiding or re-structuring the let macro. The for macro&lt;br/&gt;
can implicitly assemble a let macro for you, but with a limitation&lt;br/&gt;
that the :let clause can&apos;t be first:&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;1:5 user=&amp;gt; (for [:let [z [:foo :bar]] x z] (name x))
java.lang.IllegalStateException: Can&apos;t pop empty vector (repl-1:5)
1:6 user=&amp;gt; (for [x [:foo :bar] :let [z (name x)]] z)
(&quot;foo&quot; &quot;bar&quot;)
1:7 user=&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Is this limitation intentional?  Could the error message be improved?&lt;/p&gt;

&lt;p&gt;Here&apos;s what I wanted to write:&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;(defn add-script-links-for-imported-javascript-libraries
       [env dom-nodes]
       (extend-dom dom-nodes [:html :head] :top
               (template-for [:let [aggregation (-&amp;gt; env :cascade :resource-aggregation)
                                         libraries (@aggregation :libraries)]
                                   asset-map libraries
                                   :let [path (to-asset-path env asset-map)]]
                       :script { :type &quot;text/javascript&quot; :src path } [ linebreak ])))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(the formatting is probably scrambled)&lt;/p&gt;

&lt;p&gt;But I had to juggle it to this:&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;(defn add-script-links-for-imported-javascript-libraries
       [env dom-nodes]
       (let [aggregation (-&amp;gt; env :cascade :resource-aggregation)
              libraries (@aggregation :libraries)]
               (extend-dom dom-nodes [:html :head] :top
                       (template-for [asset-map libraries
                                           :let [path (to-asset-path env asset-map)]]
                               :script { :type &quot;text/javascript&quot; :src path } [ linebreak ]))))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course there are any number of ways to write this, but I prefer the&lt;br/&gt;
first option, as it does less of a job of obscuring what the main&lt;br/&gt;
point of the function is: a call to extend-dom.&lt;/p&gt;</description>
                <environment></environment>
            <key id="13604">CLJ-207</key>
            <summary>for macro does not allow :let clause in first position</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="-1">Unassigned</assignee>
                                <reporter username="-1">None</reporter>
                        <labels>
                    </labels>
                <created>Sun, 25 Oct 2009 09:22:00 -0500</created>
                <updated>Wed, 26 Dec 2012 05:13:49 -0600</updated>
                    <resolved>Fri, 13 Apr 2012 09:20:33 -0500</resolved>
                                                                    <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="23248" author="importer" created="Tue, 24 Aug 2010 06:56:00 -0500"  >&lt;p&gt;Converted from &lt;a href=&quot;http://www.assembla.com/spaces/clojure/tickets/207&quot;&gt;http://www.assembla.com/spaces/clojure/tickets/207&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="27981" author="tsdh" created="Thu, 22 Mar 2012 11:21:41 -0500"  >&lt;p&gt;The attached patch implements that feature and also adds tests for it.  The new tests and all other tests still pass.&lt;/p&gt;

&lt;p&gt;The patch exploits the fact that&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;(for [:let [a 1, b [1 2]], c [1 2 3]] ...)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;is equivalent to&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;(for [a [1], b [[1 2]], c [1 2 3]] ...)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and thus transforms the former binding vector to the latter.&lt;/p&gt;</comment>
                    <comment id="28133" author="richhickey" created="Fri, 13 Apr 2012 09:20:33 -0500"  >&lt;p&gt;just put the for in a let please&lt;/p&gt;</comment>
                    <comment id="30323" author="cmotricz" created="Wed, 26 Dec 2012 05:13:49 -0600"  >&lt;p&gt;I came here to report this as a bug.&lt;/p&gt;

&lt;p&gt;I respect Rich&apos;s decision to disallow :let at the beginning of a (for), of course, but I feel that if the syntax is to be declared illegal then the compiler should report an error rather than explode with an exception.&lt;/p&gt;

&lt;p&gt;Thus I suggest catching the error in the compiler and reporting it as a syntax error.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11001" name="0001-Implement-CLJ-207-let-as-first-for-binding-form.patch" size="2062" author="tsdh" created="Thu, 22 Mar 2012 11:21:41 -0500" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <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="10002">Code and Test</customfieldvalue>

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