<?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: Left folds with early termination</title>
	<atom:link href="http://www.drmaciver.com/2009/03/left-folds-with-early-termination/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 22:56:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/#comment-726</link>
		<dc:creator>david</dc:creator>
		<pubDate>Mon, 23 Mar 2009 07:55:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=440#comment-726</guid>
		<description>Frankly, because it&#039;s an awful idea. It&#039;s less flexible and more work for both the library designer and the end user. You&#039;ll get over squeamishness in the long run, you won&#039;t get over a bad API design.</description>
		<content:encoded><![CDATA[<p>Frankly, because it&#8217;s an awful idea. It&#8217;s less flexible and more work for both the library designer and the end user. You&#8217;ll get over squeamishness in the long run, you won&#8217;t get over a bad API design.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/#comment-722</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Mon, 23 Mar 2009 00:39:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=440#comment-722</guid>
		<description>Hi David,

I&#039;m wondering if Nuttycom suggestion is not the right way to go. Why not indeed overload every collection method with a termination function where needed? 

I don&#039;t necessarily mind using exceptions for control flow but as an API, it feels a bit weird:

- the &quot;stop&quot; or &quot;break&quot; method has to be imported separately from the collection import. So each time, I&#039;m using a collection, I have an additional import, just for flow control.

- there may be some scope confusion as Martin says. That may not a big deal but IIRC, programming Groovy on and off, I&#039;ve had trouble remembering what would be the effect of a &quot;return&quot; inside a &quot;collect&quot; operation.

So adding a supplementary termination function where this is useful is a bit more work on the library designer side but, as a client, it gives me a more &quot;functional feeling&quot; when using the library, with less to think about.

Eric.</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>I&#8217;m wondering if Nuttycom suggestion is not the right way to go. Why not indeed overload every collection method with a termination function where needed? </p>
<p>I don&#8217;t necessarily mind using exceptions for control flow but as an API, it feels a bit weird:</p>
<p>- the &#8220;stop&#8221; or &#8220;break&#8221; method has to be imported separately from the collection import. So each time, I&#8217;m using a collection, I have an additional import, just for flow control.</p>
<p>- there may be some scope confusion as Martin says. That may not a big deal but IIRC, programming Groovy on and off, I&#8217;ve had trouble remembering what would be the effect of a &#8220;return&#8221; inside a &#8220;collect&#8221; operation.</p>
<p>So adding a supplementary termination function where this is useful is a bit more work on the library designer side but, as a client, it gives me a more &#8220;functional feeling&#8221; when using the library, with less to think about.</p>
<p>Eric.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/#comment-714</link>
		<dc:creator>david</dc:creator>
		<pubDate>Sat, 21 Mar 2009 18:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=440#comment-714</guid>
		<description>Your post got trapped by the spam filter because of the large number of URLs. I&#039;ve approved it now.

Exceptions are in fact quite slow in C++, and the arguments about exceptions for control flow constantly harp on about performance. It is in fact a very common argument. In particular, note that it is mentioned in two of the three links you&#039;ve provided.

You will further note that you said that it appeared in &quot;literature&quot;. I promptly googled. It doesn&#039;t. It appears in a bunch of blog posts and random internet blithering. Nowhere is a useful argument presented. This includes all three of your links, all of which I had already found and dismissed. In particular searching scholar.google.com produces no valid results.

What makes me angry about your comments is that it gives us (programmers) a bad name by making everyone think that we&#039;re superstitious idiots who repeatedly assert a fear of techniques that work just fine without being able to back it up with a valid argument.

Fetch your popcorn: http://www.drmaciver.com/2009/03/exceptions-for-control-flow-considered-perfectly-acceptable-thanks-very-much/</description>
		<content:encoded><![CDATA[<p>Your post got trapped by the spam filter because of the large number of URLs. I&#8217;ve approved it now.</p>
<p>Exceptions are in fact quite slow in C++, and the arguments about exceptions for control flow constantly harp on about performance. It is in fact a very common argument. In particular, note that it is mentioned in two of the three links you&#8217;ve provided.</p>
<p>You will further note that you said that it appeared in &#8220;literature&#8221;. I promptly googled. It doesn&#8217;t. It appears in a bunch of blog posts and random internet blithering. Nowhere is a useful argument presented. This includes all three of your links, all of which I had already found and dismissed. In particular searching scholar.google.com produces no valid results.</p>
<p>What makes me angry about your comments is that it gives us (programmers) a bad name by making everyone think that we&#8217;re superstitious idiots who repeatedly assert a fear of techniques that work just fine without being able to back it up with a valid argument.</p>
<p>Fetch your popcorn: <a href="http://www.drmaciver.com/2009/03/exceptions-for-control-flow-considered-perfectly-acceptable-thanks-very-much/" rel="nofollow">http://www.drmaciver.com/2009/03/exceptions-for-control-flow-considered-perfectly-acceptable-thanks-very-much/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David R. MacIver &#187; Blog Archive &#187; Exceptions for control flow considered perfectly acceptable, thanks very much</title>
		<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/#comment-713</link>
		<dc:creator>David R. MacIver &#187; Blog Archive &#187; Exceptions for control flow considered perfectly acceptable, thanks very much</dc:creator>
		<pubDate>Sat, 21 Mar 2009 18:19:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=440#comment-713</guid>
		<description>[...] flow mechanism for collections makes me a bad person. This idiocy touches on a sore point for me. I have been invited to write a post on &#8220;Why exceptions for control flow are a good idea&#8221;. So. Here it [...]</description>
		<content:encoded><![CDATA[<p>[...] flow mechanism for collections makes me a bad person. This idiocy touches on a sore point for me. I have been invited to write a post on &#8220;Why exceptions for control flow are a good idea&#8221;. So. Here it [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve again</title>
		<link>http://www.drmaciver.com/2009/03/left-folds-with-early-termination/#comment-712</link>
		<dc:creator>Steve again</dc:creator>
		<pubDate>Sat, 21 Mar 2009 18:00:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.drmaciver.com/?p=440#comment-712</guid>
		<description>[Trying again]

Can you please not swear? It really doesn&#039;t help the debate.

Who said that the reason to not use exceptions for control flow is because they&#039;re slow? Exceptions are not slow in C++ and when they are used for control flow, the exception is thrown exactly once, which has close to no performance impact on the overall execution. You really, really need to do some homework on the subject.

Using exceptions for control flow is widely accepted as a code smell because exceptions are designed to be used when something exceptional happens.  A loop ending is not an exception condition.

There are a lot of other reasons why you should in general not do that and I&#039;m not going to enumerate them in a blog comment, but since you wanted a few references, here is a good discussion:

http://stackoverflow.com/questions/465953/throwing-exceptions-to-control-flow-code-smell

A few other references:

http://www.sturmnet.org/blog/2005/03/29/exceptions-flow
http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow

And probably the best way to do some catch up:

http://tinyurl.com/c2kncy

What makes me angry about your article is that it gives us (functional programmers) a bad name by making everyone think we don&#039;t know much about computer science fundamentals.</description>
		<content:encoded><![CDATA[<p>[Trying again]</p>
<p>Can you please not swear? It really doesn&#8217;t help the debate.</p>
<p>Who said that the reason to not use exceptions for control flow is because they&#8217;re slow? Exceptions are not slow in C++ and when they are used for control flow, the exception is thrown exactly once, which has close to no performance impact on the overall execution. You really, really need to do some homework on the subject.</p>
<p>Using exceptions for control flow is widely accepted as a code smell because exceptions are designed to be used when something exceptional happens.  A loop ending is not an exception condition.</p>
<p>There are a lot of other reasons why you should in general not do that and I&#8217;m not going to enumerate them in a blog comment, but since you wanted a few references, here is a good discussion:</p>
<p><a href="http://stackoverflow.com/questions/465953/throwing-exceptions-to-control-flow-code-smell" rel="nofollow">http://stackoverflow.com/questions/465953/throwing-exceptions-to-control-flow-code-smell</a></p>
<p>A few other references:</p>
<p><a href="http://www.sturmnet.org/blog/2005/03/29/exceptions-flow" rel="nofollow">http://www.sturmnet.org/blog/2005/03/29/exceptions-flow</a><br />
<a href="http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow" rel="nofollow">http://www.subbu.org/blog/2005/05/why-not-use-exceptions-to-control-flow</a></p>
<p>And probably the best way to do some catch up:</p>
<p><a href="http://tinyurl.com/c2kncy" rel="nofollow">http://tinyurl.com/c2kncy</a></p>
<p>What makes me angry about your article is that it gives us (functional programmers) a bad name by making everyone think we don&#8217;t know much about computer science fundamentals.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

