<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: &#8220;No-else-after-return&#8221; considered harmful</title>
	<atom:link href="http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/</link>
	<description></description>
	<lastBuildDate>Sun, 12 Feb 2012 21:54:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: palmiche</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-277</link>
		<dc:creator>palmiche</dc:creator>
		<pubDate>Wed, 02 Sep 2009 05:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-277</guid>
		<description>Benjamin Otte is right on the spot. There is a good reason behind using reserved words having an actual meaning in some spoken language. Even a skilled programmer at some point has to stop and think about the linear steps required to perform an action before actually writing the code and having language constructs with resemblance to spoken language helps writing better code and also reading someone else&#039;s. That is probably why Pascal is so easy to learn for pepole new to programming. So I don&#039;t think the else makes the code any harder to read and understand, specially when is has no damaging impact in the compiled output.

I&#039;ve just sent a survey to some senior CS students and I expect to have the results by Friday night. This is definitely a funny thing to ask to other CS students and I might do just that. ;)</description>
		<content:encoded><![CDATA[<p>Benjamin Otte is right on the spot. There is a good reason behind using reserved words having an actual meaning in some spoken language. Even a skilled programmer at some point has to stop and think about the linear steps required to perform an action before actually writing the code and having language constructs with resemblance to spoken language helps writing better code and also reading someone else&#8217;s. That is probably why Pascal is so easy to learn for pepole new to programming. So I don&#8217;t think the else makes the code any harder to read and understand, specially when is has no damaging impact in the compiled output.</p>
<p>I&#8217;ve just sent a survey to some senior CS students and I expect to have the results by Friday night. This is definitely a funny thing to ask to other CS students and I might do just that. <img src='http://blog.mozilla.com/nnethercote/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Nethercote</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-273</link>
		<dc:creator>Nicholas Nethercote</dc:creator>
		<pubDate>Mon, 31 Aug 2009 22:06:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-273</guid>
		<description>liberforce, I said in the post that I think early returns are fine for error cases like you mention.  It&#039;s for other, non-error cases (eg. in max()) that I&#039;m concerned about.</description>
		<content:encoded><![CDATA[<p>liberforce, I said in the post that I think early returns are fine for error cases like you mention.  It&#8217;s for other, non-error cases (eg. in max()) that I&#8217;m concerned about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Walden</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-272</link>
		<dc:creator>Jeff Walden</dc:creator>
		<pubDate>Mon, 31 Aug 2009 19:30:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-272</guid>
		<description>(er, s/line writing/writing/)</description>
		<content:encoded><![CDATA[<p>(er, s/line writing/writing/)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Walden</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-271</link>
		<dc:creator>Jeff Walden</dc:creator>
		<pubDate>Mon, 31 Aug 2009 19:30:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-271</guid>
		<description>Benjamin, the reason we say &quot;otherwise&quot; there is that conversation is line writing entire programs on a single line.  :-)  We have the luxury of newlines when programming, so the &quot;otherwise&quot; in that case is no longer necessary.  (Of course when you explain it to someone else you may have to translate slightly to add an &quot;otherwise&quot;, but then again, you&#039;re hardly going to say &quot;switch on the value type&quot; if you&#039;re explaining a piece of code, so you have to do some of that already.)</description>
		<content:encoded><![CDATA[<p>Benjamin, the reason we say &#8220;otherwise&#8221; there is that conversation is line writing entire programs on a single line.  <img src='http://blog.mozilla.com/nnethercote/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   We have the luxury of newlines when programming, so the &#8220;otherwise&#8221; in that case is no longer necessary.  (Of course when you explain it to someone else you may have to translate slightly to add an &#8220;otherwise&#8221;, but then again, you&#8217;re hardly going to say &#8220;switch on the value type&#8221; if you&#8217;re explaining a piece of code, so you have to do some of that already.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: liberforce</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-270</link>
		<dc:creator>liberforce</dc:creator>
		<pubDate>Mon, 31 Aug 2009 17:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-270</guid>
		<description>I&#039;ve worked on somebody&#039;s code that particularly liked the (awful) nested if-then-else style... Even worse: the error case was managed in the &#039;else&#039; part, so to see if the error case was managed I had to scroll down.

Even before that bad experience, I prefered early return, because it means &quot;ok, this case has been processed, you don&#039;t need to bother anymore&quot;, and lets you go on without that weight on your shoulders.

Now I use this 99% of the cases (and use G_LIKELY sometimes when there may be a performance issue):

if G_UNLIKELY (error == TRUE)
{
   /* process that error */
   return error_code;
}

/* more code here... */</description>
		<content:encoded><![CDATA[<p>I&#8217;ve worked on somebody&#8217;s code that particularly liked the (awful) nested if-then-else style&#8230; Even worse: the error case was managed in the &#8216;else&#8217; part, so to see if the error case was managed I had to scroll down.</p>
<p>Even before that bad experience, I prefered early return, because it means &#8220;ok, this case has been processed, you don&#8217;t need to bother anymore&#8221;, and lets you go on without that weight on your shoulders.</p>
<p>Now I use this 99% of the cases (and use G_LIKELY sometimes when there may be a performance issue):</p>
<p>if G_UNLIKELY (error == TRUE)<br />
{<br />
   /* process that error */<br />
   return error_code;<br />
}</p>
<p>/* more code here&#8230; */</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin Bate Boerop</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-269</link>
		<dc:creator>Robin Bate Boerop</dc:creator>
		<pubDate>Mon, 31 Aug 2009 15:08:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-269</guid>
		<description>Thanks for the article, Nicholas. The coding style guideline in question is overkill.  It should be removed from Mozilla&#039;s rules.</description>
		<content:encoded><![CDATA[<p>Thanks for the article, Nicholas. The coding style guideline in question is overkill.  It should be removed from Mozilla&#8217;s rules.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin Otte</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-268</link>
		<dc:creator>Benjamin Otte</dc:creator>
		<pubDate>Mon, 31 Aug 2009 10:04:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-268</guid>
		<description>I&#039;ve come to the realization in recent times that I should write code the way I&#039;d explain what the function does. So if I&#039;d say &quot;If a is greater than b, return a, otherwise return b.&quot; I&#039;d encode it with an else, if I&#039;d say &quot;Check if a is greater than b and if so, return it. Then return b.&quot; I&#039;d code it without an else.
This way, I feel the readability of my code really improves, especially when later trying to understand why the code does what it does r when trying to explain the code to someone else.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve come to the realization in recent times that I should write code the way I&#8217;d explain what the function does. So if I&#8217;d say &#8220;If a is greater than b, return a, otherwise return b.&#8221; I&#8217;d encode it with an else, if I&#8217;d say &#8220;Check if a is greater than b and if so, return it. Then return b.&#8221; I&#8217;d code it without an else.<br />
This way, I feel the readability of my code really improves, especially when later trying to understand why the code does what it does r when trying to explain the code to someone else.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: emmanuel</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-267</link>
		<dc:creator>emmanuel</dc:creator>
		<pubDate>Mon, 31 Aug 2009 09:25:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-267</guid>
		<description>i would write the max() method without the else.
it&#039;s shorter and at least for me, it&#039;s as clear as the other one, maybe even clearer (less to parse).</description>
		<content:encoded><![CDATA[<p>i would write the max() method without the else.<br />
it&#8217;s shorter and at least for me, it&#8217;s as clear as the other one, maybe even clearer (less to parse).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loup Vaillant</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-266</link>
		<dc:creator>Loup Vaillant</dc:creator>
		<pubDate>Mon, 31 Aug 2009 07:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-266</guid>
		<description>Along these lines, I go even further: I consider *assignment* harmfull (see my last blog entry).</description>
		<content:encoded><![CDATA[<p>Along these lines, I go even further: I consider *assignment* harmfull (see my last blog entry).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Sayre</title>
		<link>http://blog.mozilla.com/nnethercote/2009/08/31/no-else-after-return-considered-harmful/comment-page-1/#comment-265</link>
		<dc:creator>Rob Sayre</dc:creator>
		<pubDate>Mon, 31 Aug 2009 06:20:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mozilla.com/nnethercote/?p=165#comment-265</guid>
		<description>I think your model is incomplete. Including an &#039;else&#039; in your example shouldn&#039;t change the compiler&#039;s output. It&#039;s a talisman.</description>
		<content:encoded><![CDATA[<p>I think your model is incomplete. Including an &#8216;else&#8217; in your example shouldn&#8217;t change the compiler&#8217;s output. It&#8217;s a talisman.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

