<!-- 
RSS generated by JIRA (4.4#649-r158309) at Mon May 20 00:48:23 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/CLJS-339/CLJS-339.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>[CLJS-339] (inc nil) returns 1 instead of throwing an exception</title>
                <link>http://dev.clojure.org/jira/browse/CLJS-339</link>
                <project id="10040" key="CLJS">ClojureScript</project>
                        <description>&lt;p&gt;(inc nil) =&amp;gt; 1 in ClojureScript&lt;br/&gt;
(inc nil) =&amp;gt; raise NullPointerException in Clojure&lt;/p&gt;

&lt;p&gt;I think that Clojure&apos;s behavior (throwing) makes more sense in this context.&lt;/p&gt;</description>
                <environment></environment>
            <key id="15587">CLJS-339</key>
            <summary>(inc nil) returns 1 instead of throwing an exception</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="4" iconUrl="http://dev.clojure.org/jira/images/icons/priority_minor.gif">Minor</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="emezeske">Evan Mezeske</reporter>
                        <labels>
                        <label>bug</label>
                    </labels>
                <created>Mon, 23 Jul 2012 00:35:21 -0500</created>
                <updated>Mon, 23 Jul 2012 13:21:27 -0500</updated>
                                                                            <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="29023" author="emezeske" created="Mon, 23 Jul 2012 00:44:05 -0500"  >&lt;p&gt;I observe that in my JS console, &quot;undefined + 1 =&amp;gt; NaN&quot; but &quot;null + 1 =&amp;gt; 1&quot;.  I assume this has something to do with this issue.&lt;/p&gt;</comment>
                    <comment id="29024" author="dnolen" created="Mon, 23 Jul 2012 12:30:28 -0500"  >&lt;p&gt;Do you have any suggestions on how to make this work without slowing arithmetic down? If not I&apos;m inclined to close this as Won&apos;t Fix.&lt;/p&gt;</comment>
                    <comment id="29025" author="emezeske" created="Mon, 23 Jul 2012 12:50:48 -0500"  >&lt;p&gt;I do not.  I haven&apos;t had a chance to put a lot of thought into it, though.&lt;/p&gt;

&lt;p&gt;I consider this kind of problem to be rather insidious.  Null is not a number, and treating it as zero &lt;b&gt;will&lt;/b&gt; lead to nasty bugs creeping into people&apos;s code.&lt;/p&gt;

&lt;p&gt;A historical anecdote: the C function &quot;int atoi(char* s)&quot; takes a string and returns the number it represents.  However, if the string can&apos;t be converted, it returns zero (which could also be a valid result for e.g. the string &quot;0&quot;).  Technically, it&apos;s possible to distinguish &quot;0 meaning error&quot; and &quot;0 meaning 0&quot; by taking additional steps after the function call, but in practice people forget to do this.  Thus, atoi is universally a disaster.  I have &lt;b&gt;literally&lt;/b&gt; seen the lights go off in a warehouse due to atoi&apos;s poor design (I used to work in building control).&lt;/p&gt;

&lt;p&gt;Treating null as zero will result in similar problems.  Someone forgets to check the result of a computation, it&apos;s null, and the program silently continues as if nothing is wrong.  Hello, data corruption.&lt;/p&gt;

&lt;p&gt;So I seriously urge you to not close this as Won&apos;t Fix, even if a performant solution is not yet obvious.  IMHO it&apos;s worth more thought.&lt;/p&gt;</comment>
                    <comment id="29026" author="dnolen" created="Mon, 23 Jul 2012 12:56:35 -0500"  >&lt;p&gt;Closing as Won&apos;t Fix doesn&apos;t mean we don&apos;t care, but this issue is simply a symptom of something much larger - punting on numerics. A ticket is the wrong place for this discussion as it has many nuances. It should be a part of a larger design for ClojureScript numerics. Without that larger discussion this ticket is likely to get stuck in limbo.&lt;/p&gt;</comment>
                    <comment id="29027" author="emezeske" created="Mon, 23 Jul 2012 12:59:20 -0500"  >&lt;p&gt;Fair enough!  I thought Won&apos;t Fix had stronger implications than that.  Do you know if there&apos;s already a design doc that addresses numerics?  Or should I start one?&lt;/p&gt;</comment>
                    <comment id="29028" author="fogus" created="Mon, 23 Jul 2012 13:04:24 -0500"  >&lt;p&gt;One place that this has burned me, that may warrant a separate card is &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;(update-in some-map [:foo :bar] inc)&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; where the key at that location did not exist. I would have preferred an exception rather than an broken 1.&lt;/p&gt;</comment>
                    <comment id="29029" author="emezeske" created="Mon, 23 Jul 2012 13:09:38 -0500"  >&lt;p&gt;@Fogus: Huh, that is the &lt;b&gt;exact&lt;/b&gt; same use-case that burned me &amp;#8211; I was using update-in/inc on a nested map.  The default value for my &lt;span class=&quot;error&quot;&gt;&amp;#91;:foo :bar&amp;#93;&lt;/span&gt; was, in fact, supposed to be zero, so it silently worked for me.  But when I moved that code from the client in my webapp (ClojureScript) to the server (Clojure), I found out that my original implementation was wonky.&lt;/p&gt;</comment>
                    <comment id="29030" author="dnolen" created="Mon, 23 Jul 2012 13:17:34 -0500"  >&lt;p&gt;It doesn&apos;t seem to me that you could do that safely without fnil + 0. I too hate JS&apos;s silent failures around numerics. Been hoping someone would tackle this challenge with gusto.&lt;/p&gt;</comment>
                    <comment id="29031" author="emezeske" created="Mon, 23 Jul 2012 13:21:26 -0500"  >&lt;p&gt;@David Nolen: Yeah, fnil would do the job.  In my case, I was calling update-in on what I thought was an initialized map, but it was actually nil.  update-in initialized each level of nesting with an empty map, and then inc was called on nil.  My fix was simply to initialize the nested maps like I meant to.  &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="29032" author="fogus" created="Mon, 23 Jul 2012 13:21:27 -0500"  >&lt;p&gt;David,&lt;br/&gt;
That was ultimately the solution, so I suppose we need to start advocating this pattern so that others might avoid the same fate. &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>
                </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>