<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx</link><description>for ( long i = 0; parameters.GetCount(); i++) { What could be wrong with that?? Aaaaaaaaaaaaaaaaaargh. Curse you C++!!!!!!!!!!!!!!!! Can't that at least be a warning?</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166495</link><pubDate>Sat, 26 Jun 2004 02:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166495</guid><dc:creator>Austin Ehlers</dc:creator><description>The conditional part of the for(...) is constant, and therefore, an infinite loop will occur.&lt;br&gt;&lt;br&gt;(Duh;)</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166508</link><pubDate>Sat, 26 Jun 2004 03:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166508</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Austin: the &amp;quot;What could be wrong with that??&amp;quot; was rhetorical. &lt;br&gt;&lt;br&gt;I was more angry that C++ allows non boolean conditionals.  &lt;br&gt;&lt;br&gt;Bane of my life I tell you.</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166534</link><pubDate>Sat, 26 Jun 2004 04:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166534</guid><dc:creator>Austin Ehlers</dc:creator><description>I know. (Hence the ;) by the Duh).</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166595</link><pubDate>Sat, 26 Jun 2004 07:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166595</guid><dc:creator>Orion Adrian</dc:creator><description>While annoying at times, it's one of those power features certain people like myself miss when working with C#.&lt;br&gt;&lt;br&gt;Orion Adrian</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166621</link><pubDate>Sat, 26 Jun 2004 08:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166621</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Orion: I'm not sure I see anything powerful about that feature at all.  </description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166622</link><pubDate>Sat, 26 Jun 2004 08:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166622</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Austin: Sorry :-)&lt;br&gt;&lt;br&gt;Missed that.</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166904</link><pubDate>Sat, 26 Jun 2004 18:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166904</guid><dc:creator>thomas woelfer</dc:creator><description>Cyrus,&lt;br&gt;&lt;br&gt;i disagree. its nice to have non-boolean conditions. in c#, i hate it to be forces to write...&lt;br&gt;&lt;br&gt;object o = null;&lt;br&gt;&lt;br&gt;if( o == null)&lt;br&gt;&lt;br&gt;instead of if( o)&lt;br&gt;&lt;br&gt;yes, the c# compiler makes sure that i make sure i know what i do. but quite often, i'd rather decide myself. each time i have to write '== null', for example.&lt;br&gt;&lt;br&gt;WM_DISAGREE&lt;br&gt;thomas woelfer&lt;br&gt;</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#166958</link><pubDate>Sat, 26 Jun 2004 21:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166958</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Thomas: Again, I'm seeing no extra power in that feature :-) &lt;br&gt;&lt;br&gt;What does if (object) mean?&lt;br&gt;&lt;br&gt;I see that for you it means &amp;quot;if it exists&amp;quot;.  However, existence to me is such a vague quantity that I feel it should not be inferred by the compiler.&lt;br&gt;&lt;br&gt;For example, what does:&lt;br&gt;&lt;br&gt;if (4) { }&lt;br&gt;&lt;br&gt;mean?&lt;br&gt;&lt;br&gt;why does it mean anything else other than&lt;br&gt;&lt;br&gt;if (0) { }???&lt;br&gt;&lt;br&gt;Both are numbers, both exist.  So why should they behave differently.  Ah... because if has historical roots.  It used to mean  &amp;quot;if the expression evaluates to something with a non-bit value of all 0's then execute the following statement&amp;quot;.  However, this concept is meaningless in C#.  Numbers/Objects/instances/nulls are not thought of as just a representation of a bit pattern.  &lt;br&gt;&lt;br&gt;i.e. in C# 0, null, false are all completely different values that you can't ever assume is equivalent.  We could overload &amp;quot;if&amp;quot; to handle every type of input.  Like:&lt;br&gt;&lt;br&gt;if (int)&lt;br&gt;if (bool)&lt;br&gt;if (object)&lt;br&gt;&lt;br&gt;etc.&lt;br&gt;&lt;br&gt;However, what if we took it one step further and defined:&lt;br&gt;&lt;br&gt;if (string)&lt;br&gt;&lt;br&gt;Where we would execute the statement if the string was non-null _and_ non-empty?  Would you be ok with that?  If not, why not?  Presumably because you'd feel that &amp;quot;if&amp;quot; should only be testing against null.  But, again, I feel that this is a historical throw back.&lt;br&gt;&lt;br&gt;&amp;quot;if&amp;quot; was therefor mapped to it's logical equivalent.  In predicate logic &amp;quot;if&amp;quot; is only validly applied to an expression that will return a boolean.  So, similarly in C# we have that restriction.  Because of this we require the type to be boolean as well.&lt;br&gt;&lt;br&gt;For those worried about perf.&lt;br&gt;&lt;br&gt;The jitter would take&lt;br&gt;if (foo != 0) &lt;br&gt;and&lt;br&gt;if (foo)&lt;br&gt;and will compile down to the same assembly.  So there is nothing gained by by the brevity, except the confusion of asking yourself.  What does it mean to &amp;quot;test&amp;quot; an element from your non-boolean domain.  &lt;br&gt;&lt;br&gt;Another one to think about is structs.  How are structs tested in an &amp;quot;if&amp;quot; statement.  &lt;br&gt;&lt;br&gt;Then, once you've decided on what should happen with structs, then decide what should happen with Nullable&amp;lt;T&amp;gt;.  It's a struct.   However, it also represents a null value.  Does that suddenly mean we have to redefine what &amp;quot;if&amp;quot; means in that case?</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#167087</link><pubDate>Sun, 27 Jun 2004 06:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:167087</guid><dc:creator>James Antill</dc:creator><description> Well us &amp;quot;old time&amp;quot; C programers have just done if (foo) a lot and don't like change :).&lt;br&gt;&lt;br&gt; But, even saying that, I think that...&lt;br&gt;&lt;br&gt;if (foo) /* if foo */&lt;br&gt;&lt;br&gt;...reads a lot better than...&lt;br&gt;&lt;br&gt;if (foo != null) /* if foo not equal nothing */&lt;br&gt;&lt;br&gt;....as for the string argument, python, perl, etc. all opt. for if (foo) to do the test and have something else to just test for null ... so that's what I'd expect.&lt;br&gt; In the words of some bloke, &amp;quot;perfect is the enemy of good&amp;quot;.&lt;br&gt;</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#167134</link><pubDate>Sun, 27 Jun 2004 10:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:167134</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>I'm going to have to go with thomas and just say i disagree :-)&lt;br&gt;&lt;br&gt;&amp;quot;if foo&amp;quot; doesn't read well for me at all.  I need to at least say: &amp;quot;if foo exists&amp;quot; or &amp;quot;if i have an instance of foo&amp;quot; or &amp;quot;if foo isn't null&amp;quot;&lt;br&gt;&lt;br&gt;I think &amp;quot;if foo&amp;quot; reads well for you simply because you've been saying it a long time.  It doesn't read well for me because it's not something I can ever say in real life.   &lt;br&gt;&lt;br&gt;However, if i say &amp;quot;if foo exists&amp;quot;  or &amp;quot;if foo isn't 0&amp;quot; then that is very readable to me.&lt;br&gt;&lt;br&gt;To me, it's like saying &amp;quot;while the number of almonds, eat an almond&amp;quot;  rather than &amp;quot;while the number of almonds isn't zero, eat an almond&amp;quot;  (i'm eating almonds right now).   Conditionals like while/if/etc. just can't be spoken with any meaning unless they are applied to something domain that maps onto a logical structure (like boolean, or trinary logic). So we have to state them as something like &amp;quot;if foo exists then&amp;quot;.  or &amp;quot;if bar isn't 0&amp;quot;&lt;br&gt;&lt;br&gt;I am not content for &amp;quot;if number&amp;quot; to automatically mean &amp;quot;if number isn't 0&amp;quot;, although I _might_ be ok with the statement &amp;quot;if foo&amp;quot; being shorthand for &amp;quot;if foo exists&amp;quot;&lt;br&gt;&lt;br&gt;existence is a concept that might map into this area.  However non-zero-ness simply doesn't work for me.  &amp;quot;0&amp;quot; is not &amp;quot;does not exists&amp;quot; any more than &amp;quot;non-zero&amp;quot; is &amp;quot;exists&amp;quot;&lt;br&gt;&lt;br&gt;---&lt;br&gt;&lt;br&gt;as to the last part, i think you've explained it fully.  You expect it to behave like other programming languages.  However, which ones?  What if dylan treats it differently?  What about ruby?   What about VB?  you can't get a consensus on this because there will always be a language out there that does it differently.  </description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#167379</link><pubDate>Sun, 27 Jun 2004 21:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:167379</guid><dc:creator>Doug McClean</dc:creator><description>An even better reason why if(foo) is bad:&lt;br&gt;&lt;br&gt;Foo foo = new Foo();&lt;br&gt;FooBar foobar = new FooBar();&lt;br&gt;object obj = foobar;&lt;br&gt;if(foo) {&lt;br&gt;   Console.WriteLine(&amp;quot;Foo&amp;quot;);&lt;br&gt;}&lt;br&gt;if(foobar) {&lt;br&gt;   Console.WriteLine(&amp;quot;FooBar&amp;quot;);&lt;br&gt;}&lt;br&gt;if(obj) {&lt;br&gt;   Console.WriteLine(&amp;quot;Object&amp;quot;);&lt;br&gt;}&lt;br&gt;&lt;br&gt;What do you think it will print?&lt;br&gt;&lt;br&gt;What if I told you that, in the far away file where FooBar is defined, it says, among dozens of other things:&lt;br&gt;&lt;br&gt;class FooBar {&lt;br&gt;   ...&lt;br&gt;   public static bool operator true(FooBar foobar) {&lt;br&gt;       return false; // or other condition not established by the default constructor&lt;br&gt;   }&lt;br&gt;}&lt;br&gt;&lt;br&gt;Weren't expecting that? I wouldn't be either. But see section 7.14 of the C# defintion. Oops.</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#167386</link><pubDate>Sun, 27 Jun 2004 21:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:167386</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Doug: Don't even get me started on implicit conversions!! :-)&lt;br&gt;&lt;br&gt;Bleagh......</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#171670</link><pubDate>Fri, 02 Jul 2004 10:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:171670</guid><dc:creator>Dr Pizza</dc:creator><description>&amp;quot;What could be wrong with that??&lt;br&gt;&lt;br&gt;Aaaaaaaaaaaaaaaaaargh.  Curse you C++!!!!!!!!!!!!!!!!  Can't that at least be a warning?&amp;quot;&lt;br&gt;&lt;br&gt;What's it meant to warn you about?&lt;br&gt;&lt;br&gt;For all the compiler knows the code could be:&lt;br&gt;for(int i(0); parameters.GetCount(); ++i)&lt;br&gt;{&lt;br&gt;    cout &amp;lt;&amp;lt; &amp;quot;The &amp;quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot;th parameter is &amp;quot; &amp;lt;&amp;lt; parameters.Top() &amp;lt;&amp;lt; endl;&lt;br&gt;    parameters.PopTop();&lt;br&gt;}&lt;br&gt;</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#171674</link><pubDate>Fri, 02 Jul 2004 10:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:171674</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Dr Pizza: It's meant to warn me that the conditional expression is not actually a boolean conditional.  &lt;br&gt;&lt;br&gt;As all the posts in here have shown, i don't believe in implicit conversions.  Especially between something like numbers and booleans.  0 does not mean false in any system for me.  Just as non-zero doesn't mean true either.  &lt;br&gt;&lt;br&gt;I'm well aware of why that code compiles and runs.  But what I would like is to tell the compiler &amp;quot;warn me if the expression in the condition does not evaluate to a boolean expression.&lt;br&gt;&lt;br&gt;Does that clarify it?&lt;br&gt;</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#178426</link><pubDate>Fri, 09 Jul 2004 15:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:178426</guid><dc:creator>dung harris</dc:creator><description>if foo is a bad example. how about&lt;br&gt; if (mouseexists)</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#178430</link><pubDate>Fri, 09 Jul 2004 15:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:178430</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Dung: What about it?&lt;br&gt;&lt;br&gt;That seems perfectly reasonable if mouseExists was a boolean type...</description></item><item><title>Compiler nanny</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#191683</link><pubDate>Fri, 23 Jul 2004 01:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:191683</guid><dc:creator>Mikhail Arkhipov (MSFT)'s WebLog</dc:creator><description /></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#191687</link><pubDate>Thu, 22 Jul 2004 22:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:191687</guid><dc:creator>Mikhail Arkhipov (MSFT)</dc:creator><description>No. Stick shifts rule. :-)&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://weblogs.asp.net/mikhailarkhipov/archive/2004/07/22/191682.aspx"&gt;http://weblogs.asp.net/mikhailarkhipov/archive/2004/07/22/191682.aspx&lt;/a&gt;&lt;br&gt;</description></item><item><title>Compiler nanny</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#191690</link><pubDate>Fri, 23 Jul 2004 01:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:191690</guid><dc:creator>Mikhail Arkhipov (MSFT)'s WebLog</dc:creator><description /></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#207666</link><pubDate>Wed, 04 Aug 2004 06:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207666</guid><dc:creator>piping pepito</dc:creator><description>why hate it? say the function returns a value based on a shared memory that changes everytime? say a register, etc. isn't it a good feature?</description></item><item><title>re: Yet another reason I hate C++</title><link>http://blogs.msdn.com/cyrusn/archive/2004/06/25/166474.aspx#207804</link><pubDate>Wed, 04 Aug 2004 10:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207804</guid><dc:creator>Cyrus Najmabadi</dc:creator><description>Piping Pepito: How would that change anything?  </description></item></channel></rss>