<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: D Gotchas</title>
	<atom:link href="http://www.hans-eric.com/2007/11/06/d-gotchas/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hans-eric.com/2007/11/06/d-gotchas/</link>
	<description>Hans-Eric Grönlund on software development</description>
	<pubDate>Thu, 24 Jul 2008 10:18:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: D update mitigates comparison gotcha</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-4806</link>
		<dc:creator>D update mitigates comparison gotcha</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-4806</guid>
		<description>[...] I&#8217;ve written about in a previous post this could be a source of confusion for beginners, like myself. Someone who&#8217;s used to the [...]</description>
		<content:encoded><![CDATA[<p>[...] I&#8217;ve written about in a previous post this could be a source of confusion for beginners, like myself. Someone who&#8217;s used to the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimsotonna</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-4588</link>
		<dc:creator>jimsotonna</dc:creator>
		<pubDate>Mon, 03 Mar 2008 06:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-4588</guid>
		<description>&lt;strong&gt;jimsotonna...&lt;/strong&gt;

jimsotonna dropped by...</description>
		<content:encoded><![CDATA[<p><strong>jimsotonna&#8230;</strong></p>
<p>jimsotonna dropped by&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HeavyGod</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-1175</link>
		<dc:creator>HeavyGod</dc:creator>
		<pubDate>Tue, 27 Nov 2007 08:56:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-1175</guid>
		<description>Really good and really interesting post. I expect (and other readers maybe :)) new useful posts from you! 
Good luck and successes in blogging!</description>
		<content:encoded><![CDATA[<p>Really good and really interesting post. I expect (and other readers maybe :)) new useful posts from you!<br />
Good luck and successes in blogging!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henning</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-808</link>
		<dc:creator>Henning</dc:creator>
		<pubDate>Thu, 08 Nov 2007 14:17:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-808</guid>
		<description>Addition: You are right that similarity to C/C++ is also important for intuitivity. But maybe an optional flag that warns about such implicit conversions or something along those lines would be nice.</description>
		<content:encoded><![CDATA[<p>Addition: You are right that similarity to C/C++ is also important for intuitivity. But maybe an optional flag that warns about such implicit conversions or something along those lines would be nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henning</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-807</link>
		<dc:creator>Henning</dc:creator>
		<pubDate>Thu, 08 Nov 2007 14:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-807</guid>
		<description>There are some other unintuitive things, such as

  uint a;
  int b;

  a = 1;
  b = -3;
  writefln(a + b); // 4294967294

This may seem no problem at a first sight but when working for example with sdl where rectangle sizes are unsigned and positions are signed this produces not-too-easy trackable errors in my code regulary.

Even if I think of it at the time writing it, I find it ugly to having to cast around that much.</description>
		<content:encoded><![CDATA[<p>There are some other unintuitive things, such as</p>
<p>  uint a;<br />
  int b;</p>
<p>  a = 1;<br />
  b = -3;<br />
  writefln(a + b); // 4294967294</p>
<p>This may seem no problem at a first sight but when working for example with sdl where rectangle sizes are unsigned and positions are signed this produces not-too-easy trackable errors in my code regulary.</p>
<p>Even if I think of it at the time writing it, I find it ugly to having to cast around that much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans-Eric</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-791</link>
		<dc:creator>Hans-Eric</dc:creator>
		<pubDate>Thu, 08 Nov 2007 09:50:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-791</guid>
		<description>&lt;blockquote&gt;If D’s handling of conversions was opposite what C and C++ (and other languages) do it would confuse a lot of programmers.&lt;/blockquote&gt;
I totally agree!

&lt;blockquote&gt;If you think this through I believe you’ll conclude that C, C++, and D are doing the right thing, and the alternative you propose is actually more confusing.&lt;/blockquote&gt;
I don't agree on this one. The result of a division between two integers is most likely not an integer, so why should that be the default?</description>
		<content:encoded><![CDATA[<blockquote><p>If D’s handling of conversions was opposite what C and C++ (and other languages) do it would confuse a lot of programmers.</p></blockquote>
<p>I totally agree!</p>
<blockquote><p>If you think this through I believe you’ll conclude that C, C++, and D are doing the right thing, and the alternative you propose is actually more confusing.</p></blockquote>
<p>I don&#8217;t agree on this one. The result of a division between two integers is most likely not an integer, so why should that be the default?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans-Eric</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-790</link>
		<dc:creator>Hans-Eric</dc:creator>
		<pubDate>Thu, 08 Nov 2007 09:34:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-790</guid>
		<description>&lt;blockquote&gt;I can’t imagine how bad the confusion would be if D didn’t have 3/2 == 1. For a language that keeps such syntactic closeness to C, it would be a nightmare.&lt;/blockquote&gt;

I agree. This is of course the reason.</description>
		<content:encoded><![CDATA[<blockquote><p>I can’t imagine how bad the confusion would be if D didn’t have 3/2 == 1. For a language that keeps such syntactic closeness to C, it would be a nightmare.</p></blockquote>
<p>I agree. This is of course the reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Jorgensen</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-754</link>
		<dc:creator>Greg Jorgensen</dc:creator>
		<pubDate>Wed, 07 Nov 2007 18:49:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-754</guid>
		<description>&lt;blockquote&gt;The Premature Conversion gotcha is a particularly nasty one. It compiles and runs, which means only testing can reveal this bug.&lt;/blockquote&gt;

Presumably D is aimed at programmers who know C and C++. The premature conversion you describe is not a bug, it's how C and C++ already work. The expression itself has a type regardless of what it is ultimately assigned to. The type of dividing one integer by another is an integer. Assign that value to a real causes the type conversion.

In C:
&lt;code&gt;
    double x;

    x = 5 / 2;
    printf("%f", x);
&lt;/code&gt;

Outputs 2.000000.

If D's handling of conversions was opposite what C and C++ (and other languages) do it would confuse a lot of programmers.

If you think this through I believe you'll conclude that C, C++, and D are doing the right thing, and the alternative you propose is actually more confusing.</description>
		<content:encoded><![CDATA[<blockquote><p>The Premature Conversion gotcha is a particularly nasty one. It compiles and runs, which means only testing can reveal this bug.</p></blockquote>
<p>Presumably D is aimed at programmers who know C and C++. The premature conversion you describe is not a bug, it&#8217;s how C and C++ already work. The expression itself has a type regardless of what it is ultimately assigned to. The type of dividing one integer by another is an integer. Assign that value to a real causes the type conversion.</p>
<p>In C:<br />
<code><br />
    double x;</p>
<p>    x = 5 / 2;<br />
    printf("%f", x);<br />
</code></p>
<p>Outputs 2.000000.</p>
<p>If D&#8217;s handling of conversions was opposite what C and C++ (and other languages) do it would confuse a lot of programmers.</p>
<p>If you think this through I believe you&#8217;ll conclude that C, C++, and D are doing the right thing, and the alternative you propose is actually more confusing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sapphirecat</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-748</link>
		<dc:creator>sapphirecat</dc:creator>
		<pubDate>Wed, 07 Nov 2007 16:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-748</guid>
		<description>Python won't stay that way much longer. C-style integer division is a misfeature which will be removed in 3.0. You can also get it in Python 2.5:

from __future__ import division
a = 5/2  # 2.5
b = 5//2 # 2 (old behavior with new operator)</description>
		<content:encoded><![CDATA[<p>Python won&#8217;t stay that way much longer. C-style integer division is a misfeature which will be removed in 3.0. You can also get it in Python 2.5:</p>
<p>from __future__ import division<br />
a = 5/2  # 2.5<br />
b = 5//2 # 2 (old behavior with new operator)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Kohler</title>
		<link>http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-745</link>
		<dc:creator>Brendan Kohler</dc:creator>
		<pubDate>Wed, 07 Nov 2007 16:42:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2007/11/06/d-gotchas/#comment-745</guid>
		<description>&#62;What’s interesting is that both of these features are from Visual
&#62; Basic, and the syntax and behavior is almost identical.

They were in VB, not from it. Python, which had its first release a couple months prior to the release of VB in 1991, had the "is" operator.

No, the "is" operator is from Delphi (Object Pascal). 

All the rest of the stuff is taken directly from C.

I can't imagine how bad the confusion would be if D didn't have 3/2 == 1. For a language that keeps such syntactic closeness to C, it would be a nightmare.

No, even python never actually moved to having the default be "true division".  The great thing about integer division is how much more accurate it is than floating point, simply because you can keep exact answers by using the modulus...something floating point cannot do.</description>
		<content:encoded><![CDATA[<p>&gt;What’s interesting is that both of these features are from Visual<br />
&gt; Basic, and the syntax and behavior is almost identical.</p>
<p>They were in VB, not from it. Python, which had its first release a couple months prior to the release of VB in 1991, had the &#8220;is&#8221; operator.</p>
<p>No, the &#8220;is&#8221; operator is from Delphi (Object Pascal). </p>
<p>All the rest of the stuff is taken directly from C.</p>
<p>I can&#8217;t imagine how bad the confusion would be if D didn&#8217;t have 3/2 == 1. For a language that keeps such syntactic closeness to C, it would be a nightmare.</p>
<p>No, even python never actually moved to having the default be &#8220;true division&#8221;.  The great thing about integer division is how much more accurate it is than floating point, simply because you can keep exact answers by using the modulus&#8230;something floating point cannot do.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.268 seconds -->
