<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: On Using Guards in C++	</title>
	<atom:link href="https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Wed, 22 Jul 2020 10:35:24 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: CongressWorksForUs		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-1248</link>

		<dc:creator><![CDATA[CongressWorksForUs]]></dc:creator>
		<pubDate>Mon, 27 Aug 2018 12:24:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-1248</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-841&quot;&gt;Maxime “Selemaks” Guillem&lt;/a&gt;.

Hence the c++20 [[likely]] attribute...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-841">Maxime “Selemaks” Guillem</a>.</p>
<p>Hence the c++20 [[likely]] attribute&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Maxime “Selemaks” Guillem		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-841</link>

		<dc:creator><![CDATA[Maxime “Selemaks” Guillem]]></dc:creator>
		<pubDate>Mon, 26 Feb 2018 14:46:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-841</guid>

					<description><![CDATA[https://uploads.disquscdn.com/images/3c509b2a4724b7d8cbb0414357ef1a220ef806288edac33405c97b88436b2a09.png 

Hey we argue recently about thoses if(){return} guards with my colleagues and there was an argument that rose up in the discussion : performance.
thanks to a compiled code viewer (such as https://godbolt.org/ for instance) we saw that a code with a return at the beginning has 2 JMP instructions for the &quot;normal&quot; case, whereas if the code is inside the &quot;if&quot; statement the normal case uses no JMP at all.
And even if the compiler can optimize it for simple cases, we cannot be sure it will be properly done for more complex ones.
Hence the instruction is to not use those guards in function which are called a lot (in update loop for example).]]></description>
			<content:encoded><![CDATA[<p><a href="https://uploads.disquscdn.com/images/3c509b2a4724b7d8cbb0414357ef1a220ef806288edac33405c97b88436b2a09.png" rel="nofollow ugc">https://uploads.disquscdn.com/images/3c509b2a4724b7d8cbb0414357ef1a220ef806288edac33405c97b88436b2a09.png</a> </p>
<p>Hey we argue recently about thoses if(){return} guards with my colleagues and there was an argument that rose up in the discussion : performance.<br />
thanks to a compiled code viewer (such as <a href="https://godbolt.org/" rel="nofollow ugc">https://godbolt.org/</a> for instance) we saw that a code with a return at the beginning has 2 JMP instructions for the &#8220;normal&#8221; case, whereas if the code is inside the &#8220;if&#8221; statement the normal case uses no JMP at all.<br />
And even if the compiler can optimize it for simple cases, we cannot be sure it will be properly done for more complex ones.<br />
Hence the instruction is to not use those guards in function which are called a lot (in update loop for example).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Achilleas Margaritis		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-840</link>

		<dc:creator><![CDATA[Achilleas Margaritis]]></dc:creator>
		<pubDate>Mon, 26 Feb 2018 10:57:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-840</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-839&quot;&gt;Jonathan Boccara&lt;/a&gt;.

Well, what I have in mind is a style of programming I haven&#039;t seen anywhere: instead of returns, functions emit events, and callers can hook continuations to those events.

It&#039;s not strictly related to guards though, as a topic.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-839">Jonathan Boccara</a>.</p>
<p>Well, what I have in mind is a style of programming I haven&#8217;t seen anywhere: instead of returns, functions emit events, and callers can hook continuations to those events.</p>
<p>It&#8217;s not strictly related to guards though, as a topic.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-839</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sun, 25 Feb 2018 23:02:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-839</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-837&quot;&gt;Achilleas Margaritis&lt;/a&gt;.

Hey Achilleas, could you please clarify for me the link between early returns and event-based programming?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-837">Achilleas Margaritis</a>.</p>
<p>Hey Achilleas, could you please clarify for me the link between early returns and event-based programming?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Sharman		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-838</link>

		<dc:creator><![CDATA[Jonathan Sharman]]></dc:creator>
		<pubDate>Fri, 23 Feb 2018 23:44:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-838</guid>

					<description><![CDATA[I&#039;m a fan of this more functional style when choosing between return values:

double applyDiscount(double price)
{
    return reductionType_ == Percentage
        ? price * (1 - reductionValue_)
        : return price - reductionValue_
        ;
}]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a fan of this more functional style when choosing between return values:</p>
<p>double applyDiscount(double price)<br />
{<br />
    return reductionType_ == Percentage<br />
        ? price * (1 &#8211; reductionValue_)<br />
        : return price &#8211; reductionValue_<br />
        ;<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Achilleas Margaritis		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-837</link>

		<dc:creator><![CDATA[Achilleas Margaritis]]></dc:creator>
		<pubDate>Fri, 23 Feb 2018 14:27:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-837</guid>

					<description><![CDATA[&#062; What’s yours?

Event-based programming. Unfortunately it does not seem to be easy to do with C++.]]></description>
			<content:encoded><![CDATA[<p>&gt; What’s yours?</p>
<p>Event-based programming. Unfortunately it does not seem to be easy to do with C++.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-836</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Wed, 21 Feb 2018 16:36:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-836</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-835&quot;&gt;Vaughn Cato&lt;/a&gt;.

:) !]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-835">Vaughn Cato</a>.</p>
<p>🙂 !</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vaughn Cato		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-835</link>

		<dc:creator><![CDATA[Vaughn Cato]]></dc:creator>
		<pubDate>Wed, 21 Feb 2018 15:43:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-835</guid>

					<description><![CDATA[Unfortunately, I agree with you 100%  (It&#039;s unfortunate because it would be a more interesting discussion if I didn&#039;t).]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, I agree with you 100%  (It&#8217;s unfortunate because it would be a more interesting discussion if I didn&#8217;t).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tom Keresztes		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-834</link>

		<dc:creator><![CDATA[Tom Keresztes]]></dc:creator>
		<pubDate>Wed, 21 Feb 2018 10:32:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-834</guid>

					<description><![CDATA[The trouble with this concept that the code is far easier to read if you don&#039;t call the function if the condition is not valid. Ergo, better sort into multiple containers and only process ones that can be executed. It&#039;s simpler, reads better (is the guard always trivial?) and performs better (cache/branch predictor) . 
   And the implicit state (guard condition) is harder to write tests for.]]></description>
			<content:encoded><![CDATA[<p>The trouble with this concept that the code is far easier to read if you don&#8217;t call the function if the condition is not valid. Ergo, better sort into multiple containers and only process ones that can be executed. It&#8217;s simpler, reads better (is the guard always trivial?) and performs better (cache/branch predictor) .<br />
   And the implicit state (guard condition) is harder to write tests for.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Andrew Udvare		</title>
		<link>https://www.fluentcpp.com/2018/02/20/on-using-guards-in-cpp/#comment-833</link>

		<dc:creator><![CDATA[Andrew Udvare]]></dc:creator>
		<pubDate>Wed, 21 Feb 2018 03:14:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1708#comment-833</guid>

					<description><![CDATA[I hate when I see unnecessary else statements. I have no issue reading the so-called bad code.]]></description>
			<content:encoded><![CDATA[<p>I hate when I see unnecessary else statements. I have no issue reading the so-called bad code.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
