<!-- 
RSS generated by JIRA (4.4#649-r158309) at Wed Jun 19 21:22:37 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-859/CLJ-859.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-859] Built in dynamic vars don&apos;t have :dynamic metadata</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-859</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;I&apos;m sure &apos;built in&apos; is probably not the right term here, but I&apos;m not sure what these are called.&lt;/p&gt;

&lt;p&gt;I ran into this issue earlier today while fixing a bug in clojail. Built in vars, particularly ones listed here without a source link: &lt;a href=&quot;http://clojure.github.com/clojure/clojure.core-api.html&quot;&gt;http://clojure.github.com/clojure/clojure.core-api.html&lt;/a&gt;, do not have :dynamic metadata despite being dynamic. This includes &amp;#42;in&amp;#42;, &amp;#42;out&amp;#42;, and &amp;#42;err&amp;#42; among others. Here are some examples:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;user=&amp;gt; (meta #&apos;*err*)
{:ns #&amp;lt;Namespace clojure.core&amp;gt;, :name *err*, :added &lt;span class=&quot;code-quote&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, :doc &lt;span class=&quot;code-quote&quot;&gt;&quot;A java.io.Writer object representing standard error &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; print operations.\n\n  Defaults to &lt;span class=&quot;code-object&quot;&gt;System&lt;/span&gt;/err, wrapped in a PrintWriter&quot;&lt;/span&gt;}
user=&amp;gt; (meta #&apos;*in*)
{:ns #&amp;lt;Namespace clojure.core&amp;gt;, :name *in*, :added &lt;span class=&quot;code-quote&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, :doc &lt;span class=&quot;code-quote&quot;&gt;&quot;A java.io.Reader object representing standard input &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; read operations.\n\n  Defaults to &lt;span class=&quot;code-object&quot;&gt;System&lt;/span&gt;/in, wrapped in a LineNumberingPushbackReader&quot;&lt;/span&gt;}
user=&amp;gt; (meta #&apos;*out*)
{:ns #&amp;lt;Namespace clojure.core&amp;gt;, :name *out*, :added &lt;span class=&quot;code-quote&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, :doc &lt;span class=&quot;code-quote&quot;&gt;&quot;A java.io.Writer object representing standard output &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; print operations.\n\n  Defaults to &lt;span class=&quot;code-object&quot;&gt;System&lt;/span&gt;/out, wrapped in an OutputStreamWriter&quot;&lt;/span&gt;, :tag java.io.Writer}
user=&amp;gt; (meta #&apos;*ns*)
{:ns #&amp;lt;Namespace clojure.core&amp;gt;, :name *ns*, :added &lt;span class=&quot;code-quote&quot;&gt;&quot;1.0&quot;&lt;/span&gt;, :doc &lt;span class=&quot;code-quote&quot;&gt;&quot;A clojure.lang.Namespace object representing the current namespace.&quot;&lt;/span&gt;, :tag clojure.lang.Namespace}&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="14710">CLJ-859</key>
            <summary>Built in dynamic vars don&apos;t have :dynamic metadata</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="1" iconUrl="http://dev.clojure.org/jira/images/icons/status_open.gif">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="-1">Unassigned</assignee>
                                <reporter username="anthonysimpson">Anthony Simpson</reporter>
                        <labels>
                    </labels>
                <created>Wed, 19 Oct 2011 04:39:09 -0500</created>
                <updated>Fri, 24 Feb 2012 12:41:31 -0600</updated>
                                    <version>Release 1.3</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="27072" author="bsmith.occs@gmail.com" created="Wed, 19 Oct 2011 12:03:11 -0500"  >&lt;p&gt;This recent discussion on the users list seems relevant: &lt;a href=&quot;http://groups.google.com/group/clojure/browse_thread/thread/d5efd00c699f73a7&quot;&gt;Should intern obey :dynamic?&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It seems to boil down to this the information that a Var is dynamic (or not) is duplicated. Once as metadata with the key &lt;tt&gt;:dynamic&lt;/tt&gt;, and once as a boolean field on the Var class which implements Clojure&apos;s variables. This boolean can be obtained by calling the method &lt;tt&gt;isDynamic()&lt;/tt&gt; on the Var.&lt;/p&gt;

&lt;p&gt;The confusion arises because apparently &lt;tt&gt;:dynamic&lt;/tt&gt; and &lt;tt&gt;.isDynamic&lt;/tt&gt; can get out of sync with each other. &lt;tt&gt;.isDynamic&lt;/tt&gt; is the source of truth in this case.&lt;/p&gt;</comment>
                    <comment id="27073" author="bsmith.occs@gmail.com" created="Wed, 19 Oct 2011 12:18:22 -0500"  >&lt;p&gt;&lt;tt&gt;Compiler$Parser.parse(...)&lt;/tt&gt; finds the &lt;tt&gt;:dynamic&lt;/tt&gt; entry left in the metadata of the symbol by &lt;tt&gt;LispReader&lt;/tt&gt; and passes this on when creating a new &lt;tt&gt;DefExpr&lt;/tt&gt;, which in turn, generates the code that will call &lt;tt&gt;setDynamic(...)&lt;/tt&gt; on the var when it is created at runtime.&lt;/p&gt;

&lt;p&gt;As far as I can tell, the &lt;tt&gt;:dynamic&lt;/tt&gt; entry is irrelevant once that has occurred. It seems to be implemented only as a way to communicate (by way of the reader) with the compiler. Once the compiler&apos;s gotten the message, it isn&apos;t needed anymore. Keeping it around seems to just cause confusion.&lt;/p&gt;

&lt;p&gt;Dynamic vars created by the Java layer of Clojure core don&apos;t use the &lt;tt&gt;:dynamic&lt;/tt&gt; mechanism, they just &lt;tt&gt;setDynamic()&lt;/tt&gt; directly. That&apos;s why they don&apos;t have &lt;tt&gt;:dynamic&lt;/tt&gt; in their meta-data map. &lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Perhaps the compiler should elide &lt;tt&gt;:dynamic&lt;/tt&gt; from the metadata map available at runtime, since it has served its purpose.&lt;/li&gt;
	&lt;li&gt;Perhaps Clojure should supply the function &lt;tt&gt;dynamic?&lt;/tt&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 dynamic? [^clojure.lang.Var v] (.isDynamic v))&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Or, perhaps one might consider, for 1.4, replacing &lt;tt&gt;:dynamic&lt;/tt&gt; altogether and just enforcing the established naming convention: &lt;tt&gt;&amp;#42;earmuffs&amp;#42;&lt;/tt&gt; are dynamic, &lt;tt&gt;everything-else&lt;/tt&gt; isn&apos;t. (The compile warns about violations of this convention in 1.3.)&lt;/p&gt;</comment>
                    <comment id="27839" author="jafingerhut" created="Fri, 24 Feb 2012 11:39:08 -0600"  >&lt;p&gt;I recently noticed several lines like this one in core.clj.  Depending upon how many symbols are like this, perhaps this method could be used to add :dynamic metadata to symbols in core, along with a unit test to verify that all symbols in core have :dynamic if and only if .isDynamic returns true?&lt;/p&gt;</comment>
                    <comment id="27841" author="jafingerhut" created="Fri, 24 Feb 2012 12:41:31 -0600"  >&lt;p&gt;Ugh.  In my previous comment, by &quot;several lines like this one&quot; I meant to paste the following as an example:&lt;/p&gt;

&lt;p&gt;(alter-meta! #&apos;&lt;b&gt;agent&lt;/b&gt; assoc :added &quot;1.0&quot;)&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </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>