<?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: Loop Abstractions in D revisited</title>
	<atom:link href="http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/</link>
	<description>Hans-Eric Grönlund on software development</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:10:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: kl</title>
		<link>http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/comment-page-1/#comment-5604</link>
		<dc:creator>kl</dc:creator>
		<pubDate>Wed, 16 Apr 2008 20:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/#comment-5604</guid>
		<description>How about:
&lt;code&gt;retry!(HTTPError,5)({code});&lt;/code&gt; ?

maybe you could use &lt;code&gt;mixin&lt;/code&gt; to create nicer syntax?</description>
		<content:encoded><![CDATA[<p>How about:<br />
<code>retry!(HTTPError,5)({code});</code> ?</p>
<p>maybe you could use <code>mixin</code> to create nicer syntax?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javi</title>
		<link>http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/comment-page-1/#comment-3184</link>
		<dc:creator>Javi</dc:creator>
		<pubDate>Sun, 03 Feb 2008 20:09:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/#comment-3184</guid>
		<description>Ummm... it isn&#039;t a bug, I wrote a function to call totry() N times. Rename retry() to CallNTimes() or something like that. ; ) 
My fault, I misunderstood the idea of the article. 

Cheers!
Javi</description>
		<content:encoded><![CDATA[<p>Ummm&#8230; it isn&#8217;t a bug, I wrote a function to call totry() N times. Rename retry() to CallNTimes() or something like that. ; )<br />
My fault, I misunderstood the idea of the article. </p>
<p>Cheers!<br />
Javi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans-Eric</title>
		<link>http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/comment-page-1/#comment-3183</link>
		<dc:creator>Hans-Eric</dc:creator>
		<pubDate>Sun, 03 Feb 2008 19:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/#comment-3183</guid>
		<description>Interesting approach. Using a delegate to control the flow opens some intriguing applications. 
I think you introduced a small bug though: totry will always be invoked &lt;i&gt;times&lt;/i&gt; time. Easily fixed. Just replace

totry();

with

totry(); return;

Cheers man!</description>
		<content:encoded><![CDATA[<p>Interesting approach. Using a delegate to control the flow opens some intriguing applications.<br />
I think you introduced a small bug though: totry will always be invoked <i>times</i> time. Easily fixed. Just replace</p>
<p>totry();</p>
<p>with</p>
<p>totry(); return;</p>
<p>Cheers man!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javi</title>
		<link>http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/comment-page-1/#comment-3151</link>
		<dc:creator>Javi</dc:creator>
		<pubDate>Sat, 02 Feb 2008 15:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.hans-eric.com/2008/01/31/loop-abstractions-in-d-revisited/#comment-3151</guid>
		<description>I don&#039;t like templates... 
Why not something simple like this?: 

&lt;pre&gt;void retry(uint times, void delegate() totry, void delegate(Exception) funcex=null) 
{ 
  for(uint i = 0; i &lt; times; i++) 
  {
    try 
    {
      totry();
    } 
    catch(Exception ex) 
    { 
      if(funcex !is null) 
      { 
        funcex(ex); 

        // Or if you want to control the break the loop, 
        // define funcex as bool delegate(Exception) and: 
        // if(!funcex(ex)) 
        // { 
        //   break; 
        // }
      } 
    }
  } 
} 

// Some examples: 

// Executes MyFunc() 5 times catching all exceptions 
retry(5, &amp;MyFunc); 

// Executes MyFunc() 5 times catching all exceptions 
// and pass them to HandleMyExceptions(Exception) 
retry(5, &amp;MyFunc, &amp;HandleMyExceptions); 

// More explicit examples: 
retry(5, { writefln(&quot;hola&quot;); });  

retry(5, { writefln(&quot;hola&quot;); throw(new Exception(&quot;error!&quot;)); }, delegate(Exception ex){ writefln(ex); });&lt;/pre&gt;

Cheers, 
Javi</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like templates&#8230;<br />
Why not something simple like this?: </p>
<pre>void retry(uint times, void delegate() totry, void delegate(Exception) funcex=null)
{
  for(uint i = 0; i &lt; times; i++)
  {
    try
    {
      totry();
    }
    catch(Exception ex)
    {
      if(funcex !is null)
      {
        funcex(ex); 

        // Or if you want to control the break the loop,
        // define funcex as bool delegate(Exception) and:
        // if(!funcex(ex))
        // {
        //   break;
        // }
      }
    }
  }
} 

// Some examples: 

// Executes MyFunc() 5 times catching all exceptions
retry(5, &amp;MyFunc); 

// Executes MyFunc() 5 times catching all exceptions
// and pass them to HandleMyExceptions(Exception)
retry(5, &amp;MyFunc, &amp;HandleMyExceptions); 

// More explicit examples:
retry(5, { writefln("hola"); });  

retry(5, { writefln("hola"); throw(new Exception("error!")); }, delegate(Exception ex){ writefln(ex); });</pre>
<p>Cheers,<br />
Javi</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.319 seconds -->
