<?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: How to Design Function Parameters That Make Interfaces Easier to Use (1/3)	</title>
	<atom:link href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Mon, 10 Dec 2018 19:28:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.4</generator>
	<item>
		<title>
		By: Uri Goren		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1526</link>

		<dc:creator><![CDATA[Uri Goren]]></dc:creator>
		<pubDate>Mon, 10 Dec 2018 19:28:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1526</guid>

					<description><![CDATA[When reading code as English, &quot;myFunction(myParameter)&quot; contradicts your main point.]]></description>
			<content:encoded><![CDATA[<p>When reading code as English, &#8220;myFunction(myParameter)&#8221; contradicts your main point.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Colin Pitrat		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1506</link>

		<dc:creator><![CDATA[Colin Pitrat]]></dc:creator>
		<pubDate>Wed, 28 Nov 2018 13:37:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1506</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1492&quot;&gt;Michal R&lt;/a&gt;.

The point of the const parameter is to prevent you from doing the a++ !]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1492">Michal R</a>.</p>
<p>The point of the const parameter is to prevent you from doing the a++ !</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian Büttner		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1496</link>

		<dc:creator><![CDATA[Sebastian Büttner]]></dc:creator>
		<pubDate>Tue, 27 Nov 2018 09:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1496</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1485&quot;&gt;康小广&lt;/a&gt;.

I am pretty sure he was targeting this rule only for toplevel const. const qualified references affect the value references and are no toplevel const declarations.
A const qualifier in a toplevel declaration has no effect but documentation and belong to the implementation. In fact a toplevel const on a parameter behaves the same as:

&lt;pre&gt;
 &lt;code class=&quot;c++&quot;&gt;
    void f(int a);

    void f(int _a)
    {
      const int a = _a;
      // continue using a...
    }
 &lt;/code&gt;
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1485">康小广</a>.</p>
<p>I am pretty sure he was targeting this rule only for toplevel const. const qualified references affect the value references and are no toplevel const declarations.<br />
A const qualifier in a toplevel declaration has no effect but documentation and belong to the implementation. In fact a toplevel const on a parameter behaves the same as:</p>
<pre>
 <code class="c++">
    void f(int a);

    void f(int _a)
    {
      const int a = _a;
      // continue using a...
    }
 </code>
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1494</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Mon, 26 Nov 2018 12:50:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1494</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1491&quot;&gt;Aurélien Gâteau&lt;/a&gt;.

Thanks for noticing, this is now fixed.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1491">Aurélien Gâteau</a>.</p>
<p>Thanks for noticing, this is now fixed.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michal R		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1492</link>

		<dc:creator><![CDATA[Michal R]]></dc:creator>
		<pubDate>Sat, 24 Nov 2018 22:49:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1492</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1489&quot;&gt;jft&lt;/a&gt;.

No. As it is copied const does not matter:
&lt;code&gt;
void foo(int a)
{
  a++;
}
const int a{1};
foo(a);
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1489">jft</a>.</p>
<p>No. As it is copied const does not matter:<br />
<code><br />
void foo(int a)<br />
{<br />
  a++;<br />
}<br />
const int a{1};<br />
foo(a);<br />
</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Aurélien Gâteau		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1491</link>

		<dc:creator><![CDATA[Aurélien Gâteau]]></dc:creator>
		<pubDate>Fri, 23 Nov 2018 16:45:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1491</guid>

					<description><![CDATA[Nice article!


Typo: the return type of the f() functions in the &quot;If you declare a parameter by value const, don’t do it in the header file&quot; section should be `int`.]]></description>
			<content:encoded><![CDATA[<p>Nice article!</p>
<p>Typo: the return type of the f() functions in the &#8220;If you declare a parameter by value const, don’t do it in the header file&#8221; section should be `int`.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1490</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Fri, 23 Nov 2018 11:21:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1490</guid>

					<description><![CDATA[Another small point is that as the parameter variable name is not required in a function declaration in a header, it is often omitted - so when looking at the header all you might see is say void thisfunc(int, int, int); which is extremely unhelpful. IMO it really helps to have meaningful variable names used in function declarations. Also the names used in the declaration can be different to those used in the function definition (as they are not used by the compiler). So in the example given:

&lt;pre&gt;&lt;code&gt;
Output computeValue(Input const&#038; input, bool doCompute);
&lt;/code&gt;&lt;/pre&gt;

can be changed to 

&lt;pre&gt;&lt;code&gt;
Output computeValue(Input const&#038; input, bool useCaching);
&lt;/code&gt;&lt;/pre&gt;

without changing the definition,]]></description>
			<content:encoded><![CDATA[<p>Another small point is that as the parameter variable name is not required in a function declaration in a header, it is often omitted &#8211; so when looking at the header all you might see is say void thisfunc(int, int, int); which is extremely unhelpful. IMO it really helps to have meaningful variable names used in function declarations. Also the names used in the declaration can be different to those used in the function definition (as they are not used by the compiler). So in the example given:</p>
<pre><code>
Output computeValue(Input const&amp; input, bool doCompute);
</code></pre>
<p>can be changed to </p>
<pre><code>
Output computeValue(Input const&amp; input, bool useCaching);
</code></pre>
<p>without changing the definition,</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1489</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Fri, 23 Nov 2018 11:14:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1489</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1486&quot;&gt;Константин Третьяков&lt;/a&gt;.

It does if the passed value is truly a &#039;const&#039; and shouldn&#039;t be changed by the function.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1486">Константин Третьяков</a>.</p>
<p>It does if the passed value is truly a &#8216;const&#8217; and shouldn&#8217;t be changed by the function.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Benjamin Navarro		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1488</link>

		<dc:creator><![CDATA[Benjamin Navarro]]></dc:creator>
		<pubDate>Fri, 23 Nov 2018 10:05:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1488</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1487&quot;&gt;Lesley Lai&lt;/a&gt;.

I agree, I now tend to stay away from bool parameters as much as possible because they usually don&#039;t make any sense from the call site. Is computeValue(foo, true) is using caching or not? Have to look up the interface to be sure, but with computeValue(foo, ComputeMode::UseCache) or even something even more explicit like computeValue(foo, ComputeMode::UseCacheIfAvailable) tells everything you need to know without checking the interface or having to remember it.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1487">Lesley Lai</a>.</p>
<p>I agree, I now tend to stay away from bool parameters as much as possible because they usually don&#8217;t make any sense from the call site. Is computeValue(foo, true) is using caching or not? Have to look up the interface to be sure, but with computeValue(foo, ComputeMode::UseCache) or even something even more explicit like computeValue(foo, ComputeMode::UseCacheIfAvailable) tells everything you need to know without checking the interface or having to remember it.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Lesley Lai		</title>
		<link>https://www.fluentcpp.com/2018/11/23/function-parameters-making-interfaces-easy-to-use/#comment-1487</link>

		<dc:creator><![CDATA[Lesley Lai]]></dc:creator>
		<pubDate>Fri, 23 Nov 2018 08:54:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1951#comment-1487</guid>

					<description><![CDATA[I will use enum instead of bool for the useCaching example.]]></description>
			<content:encoded><![CDATA[<p>I will use enum instead of bool for the useCaching example.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
