<?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 Be Clear About What Your Functions Return	</title>
	<atom:link href="https://www.fluentcpp.com/2018/01/23/function-return/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/01/23/function-return/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Thu, 01 Feb 2018 14:25:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: Mihai Sebea		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-789</link>

		<dc:creator><![CDATA[Mihai Sebea]]></dc:creator>
		<pubDate>Thu, 01 Feb 2018 14:25:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-789</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-788&quot;&gt;Jonathan Boccara&lt;/a&gt;.

Thanks for the kind words :)
No we didn&#039;t check std::expected ... i&#039;ll give it a look ! 
too bad std optional doesn&#039;t support references .. 
Feel free to share the link with your readers :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-788">Jonathan Boccara</a>.</p>
<p>Thanks for the kind words 🙂<br />
No we didn&#8217;t check std::expected &#8230; i&#8217;ll give it a look !<br />
too bad std optional doesn&#8217;t support references ..<br />
Feel free to share the link with your readers 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-788</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 01 Feb 2018 12:41:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-788</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-785&quot;&gt;Mihai Sebea&lt;/a&gt;.

Went through the document and it&#039;s excellent. I&#039;d advise all the readers to have a look at your presentation on good APIs.
A couple of feedback notes:
- jtl::result is a great idea. It made me think about std::expected planned for C++20 (and Boost Outcome). Did you have a look at that?
- you may not be able to use std::optional in C++17 because std::optional does not support references (unlike boost optional)
Thanks for sharing this Mihai.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-785">Mihai Sebea</a>.</p>
<p>Went through the document and it&#8217;s excellent. I&#8217;d advise all the readers to have a look at your presentation on good APIs.<br />
A couple of feedback notes:<br />
&#8211; jtl::result is a great idea. It made me think about std::expected planned for C++20 (and Boost Outcome). Did you have a look at that?<br />
&#8211; you may not be able to use std::optional in C++17 because std::optional does not support references (unlike boost optional)<br />
Thanks for sharing this Mihai.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-786</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Wed, 31 Jan 2018 13:34:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-786</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-785&quot;&gt;Mihai Sebea&lt;/a&gt;.

Hi Mihai, I&#039;ll have a look at this document, and will provide my feedback on it.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-785">Mihai Sebea</a>.</p>
<p>Hi Mihai, I&#8217;ll have a look at this document, and will provide my feedback on it.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Mihai Sebea		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-785</link>

		<dc:creator><![CDATA[Mihai Sebea]]></dc:creator>
		<pubDate>Fri, 26 Jan 2018 21:48:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-785</guid>

					<description><![CDATA[We made a special class called result based on variant which can return a paylod or and error class 
The nice thing about this is that the error class can have an error code ( usually an enum ) and an error message.
Errors can have inner errors so you can carry errors across libraries boundaries.
The best thing about this is that in debug it asserts if the result is not checked so you always check the result before accessing the payload.
Check this presentation for more details 

https://codepatcher.wordpress.com/2017/07/04/a-tale-of-evolving-apis/

Any feedback is appreciated !]]></description>
			<content:encoded><![CDATA[<p>We made a special class called result based on variant which can return a paylod or and error class<br />
The nice thing about this is that the error class can have an error code ( usually an enum ) and an error message.<br />
Errors can have inner errors so you can carry errors across libraries boundaries.<br />
The best thing about this is that in debug it asserts if the result is not checked so you always check the result before accessing the payload.<br />
Check this presentation for more details </p>
<p><a href="https://codepatcher.wordpress.com/2017/07/04/a-tale-of-evolving-apis/" rel="nofollow ugc">https://codepatcher.wordpress.com/2017/07/04/a-tale-of-evolving-apis/</a></p>
<p>Any feedback is appreciated !</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bryce Schober		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-781</link>

		<dc:creator><![CDATA[Bryce Schober]]></dc:creator>
		<pubDate>Thu, 25 Jan 2018 21:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-781</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-779&quot;&gt;Jonathan Boccara&lt;/a&gt;.

I guess I&#039;m reconsidering strong types from a different perspective: API implementers. They are great for encouraging strict type adherence in any case. They are great in providing the facilities for the user to write expressive and optimal code... but in the case of return types, it depends entirely on API user not being lazy.

When the api user is lazy, they will use auto variables or even use the return types directly, in which case neither a typedef nor named types offers any real advantage. It seems to me that the only way to provide the real advantages that named types offer for return values is to require the user to access it via a named member - either variable or function.

And it&#039;s kinda going too far to call such a user lazy even. From what little I&#039;ve heard, auto is increasingly recommended as C++ is modernized, and direct &quot;inline&quot; usage of return types might the right thing to do for some scoping situations.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-779">Jonathan Boccara</a>.</p>
<p>I guess I&#8217;m reconsidering strong types from a different perspective: API implementers. They are great for encouraging strict type adherence in any case. They are great in providing the facilities for the user to write expressive and optimal code&#8230; but in the case of return types, it depends entirely on API user not being lazy.</p>
<p>When the api user is lazy, they will use auto variables or even use the return types directly, in which case neither a typedef nor named types offers any real advantage. It seems to me that the only way to provide the real advantages that named types offer for return values is to require the user to access it via a named member &#8211; either variable or function.</p>
<p>And it&#8217;s kinda going too far to call such a user lazy even. From what little I&#8217;ve heard, auto is increasingly recommended as C++ is modernized, and direct &#8220;inline&#8221; usage of return types might the right thing to do for some scoping situations.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-779</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 25 Jan 2018 18:19:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-779</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-772&quot;&gt;Bryce Schober&lt;/a&gt;.

Thanks for your comment Bryce. Just making sure that I understand well: what is the advantage of having the named type if they can hide it behind auto? Is it because the last of your code snippet would prevent block compilation, since the named type is not convertible to a bool?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-772">Bryce Schober</a>.</p>
<p>Thanks for your comment Bryce. Just making sure that I understand well: what is the advantage of having the named type if they can hide it behind auto? Is it because the last of your code snippet would prevent block compilation, since the named type is not convertible to a bool?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bryce Schober		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-775</link>

		<dc:creator><![CDATA[Bryce Schober]]></dc:creator>
		<pubDate>Tue, 23 Jan 2018 22:44:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-775</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-774&quot;&gt;Sebastien Dicaire&lt;/a&gt;.

Sure, I guess &quot;named-member&quot;-based interface would be a good generalization of a naming principle that is less &quot;erasable&quot;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-774">Sebastien Dicaire</a>.</p>
<p>Sure, I guess &#8220;named-member&#8221;-based interface would be a good generalization of a naming principle that is less &#8220;erasable&#8221;.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastien Dicaire		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-774</link>

		<dc:creator><![CDATA[Sebastien Dicaire]]></dc:creator>
		<pubDate>Tue, 23 Jan 2018 22:05:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-774</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/01/23/function-return/#comment-772&quot;&gt;Bryce Schober&lt;/a&gt;.

&#062;  a method-based result interface
In this case, a simple POD struct would fit the need no?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/01/23/function-return/#comment-772">Bryce Schober</a>.</p>
<p>&gt;  a method-based result interface<br />
In this case, a simple POD struct would fit the need no?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bryce Schober		</title>
		<link>https://www.fluentcpp.com/2018/01/23/function-return/#comment-772</link>

		<dc:creator><![CDATA[Bryce Schober]]></dc:creator>
		<pubDate>Tue, 23 Jan 2018 20:05:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2524#comment-772</guid>

					<description><![CDATA[Hmm... I still don&#039;t like a plain alias because it enables the user to unintentionally erase the meaning at the call site, where a named interface doesn&#039;t. If all I have is an alias, then the lazy / non-forward-thinking user may likely write something like:
&lt;pre&gt;&lt;code class=&quot;c++&quot;&gt;
bool result = save(myData); // or auto result...
&lt;/code&gt;&lt;/pre&gt;
or if they&#039;re trying to be extra efficient on typing (there lots of them out there):
&lt;pre&gt;&lt;code class=&quot;c++&quot;&gt;
if( !save(myData) ) {
  // now what?
}
&lt;/code&gt;&lt;/pre&gt;

The advantage of the named type is that it exerts a stronger forcing function of the API&#039;s user to get it right. Even if they do name their result poorly, they will still have the type info:
&lt;pre&gt;&lt;code class=&quot;c++&quot;&gt;
auto result = save(myData);
if( !result ) {
  ...
}
&lt;/code&gt;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hmm&#8230; I still don&#8217;t like a plain alias because it enables the user to unintentionally erase the meaning at the call site, where a named interface doesn&#8217;t. If all I have is an alias, then the lazy / non-forward-thinking user may likely write something like:</p>
<pre><code class="c++">
bool result = save(myData); // or auto result...
</code></pre>
<p>or if they&#8217;re trying to be extra efficient on typing (there lots of them out there):</p>
<pre><code class="c++">
if( !save(myData) ) {
  // now what?
}
</code></pre>
<p>The advantage of the named type is that it exerts a stronger forcing function of the API&#8217;s user to get it right. Even if they do name their result poorly, they will still have the type info:</p>
<pre><code class="c++">
auto result = save(myData);
if( !result ) {
  ...
}
</code></pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
