<!-- 
RSS generated by JIRA (4.4#649-r158309) at Sat May 18 06:25:00 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-461/CLJ-461.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-461] require namespace implicitly</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-461</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;Referencing a function with a fully-qualified namespace should work without first using require or use, similar to how a fully-qualified java class can be used without importing it.&lt;/p&gt;

&lt;p&gt;It&apos;s a small change in Compiler that tries to call (require x) if the fully qualified classname is not found.  This should give priority to the java class, which protects backwards compatibility.  There is no runtime performance impact, only compile time (the first time the namespace is seen).  The fact that code (the namespace) is loaded during compilation of a form is no different than loading code to look up a java class.&lt;/p&gt;

&lt;p&gt;This makes it easier to write quick scripts as in the example below, also to use one-liners in the repl or ad hoc in code.&lt;/p&gt;

&lt;p&gt;For example: java -cp src/clj/:classes clojure.main -e &quot;(clojure.set/union #{1} #{2})&quot;&lt;br/&gt;
&lt;br/&gt;
Currently on master, this produces: Exception in thread &quot;main&quot; java.lang.ClassNotFoundException: clojure.set&lt;br/&gt;
but this works: java -cp src/clj/:classes clojure.main -e &quot;(require &apos;clojure.set) (clojure.set/union #{1} #{2})&quot;&lt;/p&gt;

&lt;p&gt;Obviously, (use) would make the code shorter, but my goal is to make it implicit.&lt;/p&gt;

&lt;p&gt;Discussion: &lt;a href=&quot;http://groups.google.com/group/clojure-dev/t/69823ce63dd94a0c&quot;&gt;http://groups.google.com/group/clojure-dev/t/69823ce63dd94a0c&lt;/a&gt;&lt;/p&gt;</description>
                <environment></environment>
            <key id="13858">CLJ-461</key>
            <summary>require namespace implicitly</summary>
                <type id="4" iconUrl="http://dev.clojure.org/jira/images/icons/improvement.gif">Enhancement</type>
                                <priority id="1" iconUrl="http://dev.clojure.org/jira/images/icons/priority_blocker.gif">Blocker</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="2">Declined</resolution>
                                <assignee username="mikehinchey">Mike Hinchey</assignee>
                                <reporter username="mikehinchey">Mike Hinchey</reporter>
                        <labels>
                    </labels>
                <created>Sat, 16 Oct 2010 02:41:00 -0500</created>
                <updated>Tue, 21 Jun 2011 18:41:38 -0500</updated>
                    <resolved>Tue, 21 Jun 2011 18:41:38 -0500</resolved>
                                            <fixVersion>Backlog</fixVersion>
                                        <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="24311" author="importer" created="Sun, 17 Oct 2010 21:37:00 -0500"  >&lt;p&gt;Converted from &lt;a href=&quot;http://www.assembla.com/spaces/clojure/tickets/461&quot;&gt;http://www.assembla.com/spaces/clojure/tickets/461&lt;/a&gt;&lt;br/&gt;
Attachments:&lt;br/&gt;
mh-461-require.patch - &lt;a href=&quot;https://www.assembla.com/spaces/clojure/documents/cQSfQ22L8r37zxeJe5cbCb/download/cQSfQ22L8r37zxeJe5cbCb&quot;&gt;https://www.assembla.com/spaces/clojure/documents/cQSfQ22L8r37zxeJe5cbCb/download/cQSfQ22L8r37zxeJe5cbCb&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="24312" author="importer" created="Sun, 17 Oct 2010 21:37:00 -0500"  >&lt;p&gt;mikehinchey said: [&lt;a href=&quot;file:cQSfQ22L8r37zxeJe5cbCb&quot;&gt;file:cQSfQ22L8r37zxeJe5cbCb&lt;/a&gt;]: patch to fix #461&lt;/p&gt;</comment>
                    <comment id="24313" author="importer" created="Sun, 17 Oct 2010 21:37:00 -0500"  >&lt;p&gt;mikehinchey said: The discussion shows some people want this, other&apos;s aren&apos;t sure.  Attached the patch so people can try it out.&lt;/p&gt;</comment>
                    <comment id="26025" author="stuart.sierra" created="Sun, 12 Dec 2010 16:06:47 -0600"  >&lt;p&gt;One problem I see: With this change, it becomes harder for code-reading tools to determine all the dependencies of a namespace without evaluating it. Right now, I can &lt;a href=&quot;https://github.com/stuartsierra/lazytest/blob/86a75572e81625b09f9ed15981fb9efd670e00a9/modules/lazytest/src/main/clojure/lazytest/nsdeps.clj&quot;&gt;parse the &quot;ns&quot; declaration&lt;/a&gt; of any file and know its dependencies. (Obviously, this breaks if the file loads code outside of the &quot;ns&quot; declaration, but then static analysis is virtually impossible.) &lt;/p&gt;

&lt;p&gt;With this change, the &quot;ns&quot; declaration no longer represents the complete set of dependencies for the namespace. I can try to read the whole file, but I have no way of knowing if &quot;foo.bar.baz/quux&quot; represents a namespace-qualified symbol or a static Java member, unless I evaluate it.&lt;/p&gt;

&lt;p&gt;I think loading Java classes and loading Clojure namespaces are fundamentally different operations because classes, unlike namespaces, cannot change after they are loaded.&lt;/p&gt;</comment>
                    <comment id="26500" author="pjstadig" created="Fri, 10 Jun 2011 14:01:27 -0500"  >&lt;p&gt;Stuart,&lt;br/&gt;
On the first point: it is already hard for code-reading tools.  One can (require &apos;something) outside of the ns form.  There are also uses of eval, direct references to fully qualified classes, and other nefarious ways.  You seem to have admitted this already, so I&apos;m not quite sure what you are objecting to?  Objection 1: OVERRULED.&lt;/p&gt;

&lt;p&gt;On the second point: you already admitted above that the ns declaration doesn&apos;t represent the complete set of dependencies, so there is no &quot;no longer&quot; about it.  It was just never the case.  Secondly, &quot;foo.bar.baz/quux&quot; could be a static Java member, or a Clojure Var, but that is irrelevant to this patch.  That was always the case, and the patch is about autoloading, not about interpreting to what &quot;foo.bar.baz/quux&quot; is referring.  Objection 2: OVERRULED.&lt;/p&gt;

&lt;p&gt;On the third point: again, I don&apos;t see the relevance of the fact that a namespace can be changed after it has been loaded but a class cannot.  Again, the patch is about autoloading, and the immutability/mutability of namespaces vs. classes is orthogonal.  Objection 3: OVERRULED.&lt;/p&gt;

&lt;p&gt;Finally, the original ML thread that spawned this had a +1 from the following persons: myself, Christophe Grand, Phil Hagelberg, Laurent Petit, Steve Gilardi, Cosmin Stejerean, and Chas Emerick.&lt;/p&gt;

&lt;p&gt;It had a -1 only from: you, Dimitry Gashinsky.&lt;/p&gt;

&lt;p&gt;A negative comment from Stu Halloway, and a positive-ish comment from Chris Houser.&lt;/p&gt;

&lt;p&gt;I say we move forward with this.&lt;/p&gt;</comment>
                    <comment id="26501" author="hiredman" created="Fri, 10 Jun 2011 14:07:21 -0500"  >&lt;p&gt;I have serious reservations about the complexity this will add to the compiler. the current patch is no good, it will break for aot compilation.&lt;/p&gt;</comment>
                    <comment id="26502" author="pjstadig" created="Fri, 10 Jun 2011 14:21:52 -0500"  >&lt;p&gt;So I&apos;ve been told that my tongue-in-cheek may not have translated well, but that was the intent.  I apologize if that was the case.&lt;/p&gt;

&lt;p&gt;My point is just to draw attention to this ticket again.  It was discussed on the ML with several +1&apos;s and has been mentioned again in chat.  I don&apos;t think any of the objections that Stuart Sierra raised are particularly relevant to the question of autoloading the namespace of a fully qualified var.&lt;/p&gt;

&lt;p&gt;Has anyone tried the patch?  Kevin Downey seems to think it will not work in the context of AOT.&lt;/p&gt;

&lt;p&gt;Do we need a new patch?&lt;/p&gt;</comment>
                    <comment id="26503" author="hiredman" created="Fri, 10 Jun 2011 14:27:08 -0500"  >&lt;p&gt;the patch doesn&apos;t actually cause code to load the required namespaces to be generated. it only loads the required namespaces during compilation, which is why it breaks aot. once you get into code generation for aot it gets complicated, where does the generated code go? do we want to try and emit it separately like the requires from an ns form or does it get emitted in the middle of the particular function being compiled. I think the first approach is desirable from a stand point of correctness, but carries with it a load of complexity.&lt;/p&gt;</comment>
                    <comment id="26504" author="pjstadig" created="Fri, 10 Jun 2011 15:00:24 -0500"  >&lt;p&gt;I think it gets emitted in the middle of a function, just like would happen now if you do (require &apos;clojure.set) (clojure.set/union ...)&lt;/p&gt;

&lt;p&gt;Is there a benefit to having it emit separately like an ns form?  Isn&apos;t the ns form just a macro that turns into calls to (require ...) which happen to be at the top of a file because that&apos;s where the ns form is?&lt;/p&gt;</comment>
                    <comment id="26529" author="richhickey" created="Tue, 21 Jun 2011 18:41:24 -0500"  >&lt;p&gt;This is not a good idea, for many reasons, the simplest of which is: it makes loading a side effect of calling a function in a module. Since loading can have arbitrary effects, it shouldn&apos;t be implicit. This isn&apos;t warranted by the meager benefits it might provide.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </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>
                                                                                                            </customfields>
    </item>
</channel>
</rss>