<?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: Making code expressive with lambdas	</title>
	<atom:link href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Fri, 08 Dec 2017 15:04: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: David Brown		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-701</link>

		<dc:creator><![CDATA[David Brown]]></dc:creator>
		<pubDate>Fri, 08 Dec 2017 15:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-701</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-76&quot;&gt;Puneet Agrawal&lt;/a&gt;.

Using this form, without the wrapping function, also means you can make a named lambda at local scope within a function.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-76">Puneet Agrawal</a>.</p>
<p>Using this form, without the wrapping function, also means you can make a named lambda at local scope within a function.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-412</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Mon, 17 Jul 2017 16:21:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-412</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-411&quot;&gt;Ingo&lt;/a&gt;.

Indeed! Typo fixed, thanks.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-411">Ingo</a>.</p>
<p>Indeed! Typo fixed, thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ingo		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-411</link>

		<dc:creator><![CDATA[Ingo]]></dc:creator>
		<pubDate>Mon, 17 Jul 2017 05:32:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-411</guid>

					<description><![CDATA[A possible advantage of the lambda: since the code is right there, you see what it does, instead of trusting the name. (The IsBetween functor does not check if x is between a and b, it checks if it&#039;s greater than both:

bool operator()(int x) { return a_ &#060;= x &#038;&#038; b_ &#060;= x; }
vs
[a,b](int x) { return a &#060;= x &#038;&#038; x &#060;= b; });)]]></description>
			<content:encoded><![CDATA[<p>A possible advantage of the lambda: since the code is right there, you see what it does, instead of trusting the name. (The IsBetween functor does not check if x is between a and b, it checks if it&#8217;s greater than both:</p>
<p>bool operator()(int x) { return a_ &lt;= x &amp;&amp; b_ &lt;= x; }<br />
vs<br />
[a,b](int x) { return a &lt;= x &amp;&amp; x &lt;= b; });)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-257</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Tue, 09 May 2017 17:29:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-257</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-254&quot;&gt;rocktale&lt;/a&gt;.

Thanks for the appreciation. If you like the theme, don&#039;t hesitate to let me know what particular topic you&#039;d like to read about!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-254">rocktale</a>.</p>
<p>Thanks for the appreciation. If you like the theme, don&#8217;t hesitate to let me know what particular topic you&#8217;d like to read about!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: rocktale		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-254</link>

		<dc:creator><![CDATA[rocktale]]></dc:creator>
		<pubDate>Mon, 08 May 2017 19:23:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-254</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-253&quot;&gt;Jonathan Boccara&lt;/a&gt;.

Thanks for the hint with the book. I read it a while ago but apparently forgot much of it already. ;-) However, things are a bit clearer now. Thank you for the great work, I always enjoy reading your posts.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-253">Jonathan Boccara</a>.</p>
<p>Thanks for the hint with the book. I read it a while ago but apparently forgot much of it already. 😉 However, things are a bit clearer now. Thank you for the great work, I always enjoy reading your posts.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-253</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Mon, 08 May 2017 14:38:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-253</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-250&quot;&gt;rocktale&lt;/a&gt;.

Fair enough, I get your point.
And about your last question, you may be interested in reading Item 34 of  Scott Meyers&#039; Effective Modern C++, where he provides a very detailed answer.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-250">rocktale</a>.</p>
<p>Fair enough, I get your point.<br />
And about your last question, you may be interested in reading Item 34 of  Scott Meyers&#8217; Effective Modern C++, where he provides a very detailed answer.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: rocktale		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-250</link>

		<dc:creator><![CDATA[rocktale]]></dc:creator>
		<pubDate>Sun, 07 May 2017 21:00:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-250</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-247&quot;&gt;Jonathan Boccara&lt;/a&gt;.

I agree, readability on the call site is significantly improved. However, I was thinking that the logic within the resist function might be needed some place else and than it would be strange to call a function returning a function with the logic. Thus, I assume the implementation of the logic within the lambda in resists() already exists, e.g. as a free function. 

If that is the case, there are (at least) 4 options for copy_if:
1) use std::bind
2) use a lambda within copy_if that forwards to the free function
3) use a function returning the result of std::bind
4) use a function returning a lambda that forwards to the free function 

While 1) and 2) are a bit cluttered on the call site, 3) and 4) feel a bit overengineered. The level of abstraction would already be ok with 1) and 2) and another indirection makes the code harder to navigate. I think, I&#039;d still go with option 1. I was just wondering, why std::bind seems to be replaced by lambdas all over the place.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-247">Jonathan Boccara</a>.</p>
<p>I agree, readability on the call site is significantly improved. However, I was thinking that the logic within the resist function might be needed some place else and than it would be strange to call a function returning a function with the logic. Thus, I assume the implementation of the logic within the lambda in resists() already exists, e.g. as a free function. </p>
<p>If that is the case, there are (at least) 4 options for copy_if:<br />
1) use std::bind<br />
2) use a lambda within copy_if that forwards to the free function<br />
3) use a function returning the result of std::bind<br />
4) use a function returning a lambda that forwards to the free function </p>
<p>While 1) and 2) are a bit cluttered on the call site, 3) and 4) feel a bit overengineered. The level of abstraction would already be ok with 1) and 2) and another indirection makes the code harder to navigate. I think, I&#8217;d still go with option 1. I was just wondering, why std::bind seems to be replaced by lambdas all over the place.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-247</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sun, 07 May 2017 00:09:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-247</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-246&quot;&gt;rocktale&lt;/a&gt;.

The benefit I would see is that the calling code doesn&#039;t show &quot;bind&quot; nor its accompanying placeholders, which, in my opinion, are extra info hindering the readability of the call site.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-246">rocktale</a>.</p>
<p>The benefit I would see is that the calling code doesn&#8217;t show &#8220;bind&#8221; nor its accompanying placeholders, which, in my opinion, are extra info hindering the readability of the call site.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: rocktale		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-246</link>

		<dc:creator><![CDATA[rocktale]]></dc:creator>
		<pubDate>Sat, 06 May 2017 10:20:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-246</guid>

					<description><![CDATA[I was wondering, what is the benefit of the free function &#039;resists&#039; returning a lambda over implementing the algorithm directly in the free function an using std::bind in the call to copy_if?]]></description>
			<content:encoded><![CDATA[<p>I was wondering, what is the benefit of the free function &#8216;resists&#8217; returning a lambda over implementing the algorithm directly in the free function an using std::bind in the call to copy_if?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-216</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 20 Apr 2017 13:40:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=500#comment-216</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-206&quot;&gt;Juraj Plavcan&lt;/a&gt;.

Yep. The only case I can see where things could go wrong is if the const&#038; passed to the function is the result of an implicit conversion. In this case, the converted object is destroyed when the function returns, and the lambda would still hold a reference to it. But this is not the case here, and implicit conversion are advised against in general (but there is one from string literals to std::string!)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/01/19/making-code-expressive-lambdas/#comment-206">Juraj Plavcan</a>.</p>
<p>Yep. The only case I can see where things could go wrong is if the const&amp; passed to the function is the result of an implicit conversion. In this case, the converted object is destroyed when the function returns, and the lambda would still hold a reference to it. But this is not the case here, and implicit conversion are advised against in general (but there is one from string literals to std::string!)</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
