<?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 for Left Right Fold</title>
	<atom:link href="http://leftrightfold.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://leftrightfold.com</link>
	<description>Conventional programs consist of 90% assignment statements</description>
	<pubDate>Wed, 10 Mar 2010 08:15:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on The death of if-else, if, and else by EastZoneSoupCube - Linklist: Programming</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1137</link>
		<dc:creator>EastZoneSoupCube - Linklist: Programming</dc:creator>
		<pubDate>Sat, 16 Jan 2010 15:48:48 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1137</guid>
		<description>[...] Left Right Fold: The death of if-else, if, and else [...]</description>
		<content:encoded><![CDATA[<p>[...] Left Right Fold: The death of if-else, if, and else [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Cihat</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1098</link>
		<dc:creator>Cihat</dc:creator>
		<pubDate>Wed, 16 Dec 2009 07:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1098</guid>
		<description>This is also named as "Table Driven Method" in famous  Code Complete 2 book.</description>
		<content:encoded><![CDATA[<p>This is also named as &#8220;Table Driven Method&#8221; in famous  Code Complete 2 book.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by HumbleMonkey</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1094</link>
		<dc:creator>HumbleMonkey</dc:creator>
		<pubDate>Mon, 14 Dec 2009 16:24:40 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1094</guid>
		<description>The article is titled "The Death of If-else, if, and else", and you use if, else if.
hmmmmm, and we are to take you advise seriously.</description>
		<content:encoded><![CDATA[<p>The article is titled &#8220;The Death of If-else, if, and else&#8221;, and you use if, else if.<br />
hmmmmm, and we are to take you advise seriously.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Twitted by delicious50</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1093</link>
		<dc:creator>Twitted by delicious50</dc:creator>
		<pubDate>Mon, 14 Dec 2009 13:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1093</guid>
		<description>[...] This post was Twitted by delicious50 [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was Twitted by delicious50 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Twitted by karolk</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1091</link>
		<dc:creator>Twitted by karolk</dc:creator>
		<pubDate>Mon, 14 Dec 2009 05:29:42 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1091</guid>
		<description>[...] This post was Twitted by karolk [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was Twitted by karolk [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Twitted by hackernws</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1090</link>
		<dc:creator>Twitted by hackernws</dc:creator>
		<pubDate>Mon, 14 Dec 2009 05:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1090</guid>
		<description>[...] This post was Twitted by hackernws [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was Twitted by hackernws [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by sshaw</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1086</link>
		<dc:creator>sshaw</dc:creator>
		<pubDate>Tue, 08 Dec 2009 06:45:56 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1086</guid>
		<description>Oh wait, never mind... I missed the point</description>
		<content:encoded><![CDATA[<p>Oh wait, never mind&#8230; I missed the point</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by sshaw</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1085</link>
		<dc:creator>sshaw</dc:creator>
		<pubDate>Tue, 08 Dec 2009 06:41:44 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1085</guid>
		<description>I agree that this is another good way to eliminate massive if-then-else in some cases, though I  think the example would be better illustrated as:

&lt;pre lang="javascript"&gt;
var actions = {
    "football": function (channel)  { return true },
    "comedy" : function (channel) { return !channel.repeat },
    "crime" : function (channel)    { return (channel.showTitle != "Cops") }
};

function surf_dispatch(channels, actions) {
  for(var number in channels) {
   if(actions[channels[number].genre](channels[number])) {
     record(channels[number])
   }
  } 
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I agree that this is another good way to eliminate massive if-then-else in some cases, though I  think the example would be better illustrated as:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> actions <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;football&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>channel<span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;comedy&quot;</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>channel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">!</span>channel.<span style="color: #660066;">repeat</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;crime&quot;</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>channel<span style="color: #009900;">&#41;</span>    <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>channel.<span style="color: #660066;">showTitle</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;Cops&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> surf_dispatch<span style="color: #009900;">&#40;</span>channels<span style="color: #339933;">,</span> actions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> number <span style="color: #000066; font-weight: bold;">in</span> channels<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>actions<span style="color: #009900;">&#91;</span>channels<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">genre</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span>channels<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     record<span style="color: #009900;">&#40;</span>channels<span style="color: #009900;">&#91;</span>number<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Kumar</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1081</link>
		<dc:creator>Kumar</dc:creator>
		<pubDate>Mon, 07 Dec 2009 09:50:17 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1081</guid>
		<description>Checkout "No ifs, ands or buts", a presentation of the experimental "Subtext" programming environment explicitly built to tackle the problem you're talking about.

http://subtextual.org/subtext2.html</description>
		<content:encoded><![CDATA[<p>Checkout &#8220;No ifs, ands or buts&#8221;, a presentation of the experimental &#8220;Subtext&#8221; programming environment explicitly built to tackle the problem you&#8217;re talking about.</p>
<p><a href="http://subtextual.org/subtext2.html" rel="nofollow">http://subtextual.org/subtext2.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Larry Battle</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1078</link>
		<dc:creator>Larry Battle</dc:creator>
		<pubDate>Mon, 07 Dec 2009 03:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1078</guid>
		<description>What about something like this...
&lt;code&gt;
switch{
case (genre === "comedy" &#38;&#38; !repeat): 
case (genre === "crime" &#38;&#38; showTitle !== "Cops"): 
case (genre === "football"): 
	record(channels[number]);
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>What about something like this&#8230;<br />
<code><br />
switch{<br />
case (genre === "comedy" &amp;&amp; !repeat):<br />
case (genre === "crime" &amp;&amp; showTitle !== "Cops"):<br />
case (genre === "football"):<br />
	record(channels[number]);<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by More On The Death of If-Else</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1077</link>
		<dc:creator>More On The Death of If-Else</dc:creator>
		<pubDate>Mon, 07 Dec 2009 02:27:18 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1077</guid>
		<description>[...] On The Death of If-Else Aaron Feng posted recently on “The death of if-else, if, and else”. In the post Aaron rewrote some JavaScript conditional checks using a dispatch table type [...]</description>
		<content:encoded><![CDATA[<p>[...] On The Death of If-Else Aaron Feng posted recently on “The death of if-else, if, and else”. In the post Aaron rewrote some JavaScript conditional checks using a dispatch table type [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Stylianos</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1076</link>
		<dc:creator>Stylianos</dc:creator>
		<pubDate>Sun, 06 Dec 2009 23:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1076</guid>
		<description>I have been using this approach in php a lot and since javascript supports eval type of functionality you can also add dispatch information such that you can filter actions easier. 

I am all pro this approach as a tabular format of action/reactions seems much more coherent and legible than nasty conditional tree. It is not that they magically disappear, but just that they don't sit in the foreground</description>
		<content:encoded><![CDATA[<p>I have been using this approach in php a lot and since javascript supports eval type of functionality you can also add dispatch information such that you can filter actions easier. </p>
<p>I am all pro this approach as a tabular format of action/reactions seems much more coherent and legible than nasty conditional tree. It is not that they magically disappear, but just that they don&#8217;t sit in the foreground</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by nbspnbsp</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1075</link>
		<dc:creator>nbspnbsp</dc:creator>
		<pubDate>Sun, 06 Dec 2009 22:39:44 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1075</guid>
		<description>My vote is for using switch as well. Also double-spaces after periods? On the web?</description>
		<content:encoded><![CDATA[<p>My vote is for using switch as well. Also double-spaces after periods? On the web?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Tom Janssens</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1073</link>
		<dc:creator>Tom Janssens</dc:creator>
		<pubDate>Sun, 06 Dec 2009 20:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1073</guid>
		<description>Just a small suggestion: imho you should include all the fields in the decision table ( showname &#38; repeat ), using lambda's for example. Then you can avoid the much hated if's in your example delegates.</description>
		<content:encoded><![CDATA[<p>Just a small suggestion: imho you should include all the fields in the decision table ( showname &amp; repeat ), using lambda&#8217;s for example. Then you can avoid the much hated if&#8217;s in your example delegates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by leipie</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1072</link>
		<dc:creator>leipie</dc:creator>
		<pubDate>Sun, 06 Dec 2009 19:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1072</guid>
		<description>I believe almost the same behavior can be obtained by using a switch with each case calling its own function. (A switch uses a sorts of jump table) This also solves the default actions issue. The only thing you need to type extra is the break statement. (Which is handy to leave out in some cases ;)
Also anonymous functions scream code replication, so if you put normal functions references in your actions array It becomes even more similar to a switch. (I hate code replication ;)</description>
		<content:encoded><![CDATA[<p>I believe almost the same behavior can be obtained by using a switch with each case calling its own function. (A switch uses a sorts of jump table) This also solves the default actions issue. The only thing you need to type extra is the break statement. (Which is handy to leave out in some cases <img src='http://leftrightfold.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Also anonymous functions scream code replication, so if you put normal functions references in your actions array It becomes even more similar to a switch. (I hate code replication <img src='http://leftrightfold.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by ClipperHouse &#124; Logic as data</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1071</link>
		<dc:creator>ClipperHouse &#124; Logic as data</dc:creator>
		<pubDate>Sun, 06 Dec 2009 19:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1071</guid>
		<description>[...] This article demonstrates a pattern to avoid brittle if-then statements. The idea is that, instead of very long conditional branches, one encapsulates evaluation logic in a table of data. Each data item is a function containing an arbitrary piece of logic – code which runs after being passed to another function. When you need to add new conditional logic, you add a new item to the table – no code changes to your main algorithm. This is very extensible. [...]</description>
		<content:encoded><![CDATA[<p>[...] This article demonstrates a pattern to avoid brittle if-then statements. The idea is that, instead of very long conditional branches, one encapsulates evaluation logic in a table of data. Each data item is a function containing an arbitrary piece of logic – code which runs after being passed to another function. When you need to add new conditional logic, you add a new item to the table – no code changes to your main algorithm. This is very extensible. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by The death of if-else, if, and else &#8211; Left Right Fold &#171; Netcrema &#8211; creme de la social news via digg + delicious + stumpleupon + reddit</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1070</link>
		<dc:creator>The death of if-else, if, and else &#8211; Left Right Fold &#171; Netcrema &#8211; creme de la social news via digg + delicious + stumpleupon + reddit</dc:creator>
		<pubDate>Sun, 06 Dec 2009 18:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1070</guid>
		<description>[...] The death of if-else, if, and else &#8211; Left Right Foldleftrightfold.com [...]</description>
		<content:encoded><![CDATA[<p>[...] The death of if-else, if, and else &#8211; Left Right Foldleftrightfold.com [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Torbjørn Marø</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1069</link>
		<dc:creator>Torbjørn Marø</dc:creator>
		<pubDate>Sun, 06 Dec 2009 17:47:56 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1069</guid>
		<description>[edit of previous...]

My co-worker actually presented this pattern in a ziptalk on Friday - without knowing the name. I called it a kind of table method patter implementation, and it has also a lot in common with Strategy Pattern (it IS strategy pattern, without objects).

So &lt;i&gt;dispatch pattern&lt;/i&gt; it is then. It shows up more and more in my own code (C# mostly), and makes the code much more maintainable.</description>
		<content:encoded><![CDATA[<p>[edit of previous...]</p>
<p>My co-worker actually presented this pattern in a ziptalk on Friday - without knowing the name. I called it a kind of table method patter implementation, and it has also a lot in common with Strategy Pattern (it IS strategy pattern, without objects).</p>
<p>So <i>dispatch pattern</i> it is then. It shows up more and more in my own code (C# mostly), and makes the code much more maintainable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Bram Stein</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1067</link>
		<dc:creator>Bram Stein</dc:creator>
		<pubDate>Sun, 06 Dec 2009 17:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1067</guid>
		<description>I've been experimenting with functional pattern matching in JavaScript (see: &lt;a href="http://www.bramstein.com/projects/jfun/" rel="nofollow"&gt;http://www.bramstein.com/projects/jfun/&lt;/a&gt;).

Using my experiments, you could rewrite your code as follows:
&lt;pre lang="javascript"&gt;&lt;code&gt;
  function record(channel) {
    console.log("recording channel: " + channel);
  }

  var surf = fun(
    [{genre: 'football', showTitle: _, repeat: _, station: _}, $, record],
    [{genre: 'comedy', showTitle: _, repeat: false, station: _}, $, record],
    [{genre: 'crime', showTitle: 'Cops', repeat: _, station: _}, $, record],
    [{genre: _, showTitle: _, repeat: _, station: _}, $, function () {}]
  );

  Object.forEach(channels, function (channel, number) {
    surf(channel, number);
  });
&lt;/pre&gt;&lt;/code&gt;
The last case in the pattern match is a catch-all to make the match exhaustive.

I'm not sure if implementing pattern matching on top of JavaScript is a good idea though. The syntax especially suffers. I've been thinking about moving the pattern matching into a preprocessor, but then it wouldn't be JavaScript anymore :)</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with functional pattern matching in JavaScript (see: <a href="http://www.bramstein.com/projects/jfun/" rel="nofollow">http://www.bramstein.com/projects/jfun/</a>).</p>
<p>Using my experiments, you could rewrite your code as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span>
  <span style="color: #003366; font-weight: bold;">function</span> record<span style="color: #009900;">&#40;</span>channel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;recording channel: &quot;</span> <span style="color: #339933;">+</span> channel<span style="color: #009900;">&#41;</span>;
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> surf <span style="color: #339933;">=</span> fun<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>genre<span style="color: #339933;">:</span> <span style="color: #3366CC;">'football'</span><span style="color: #339933;">,</span> showTitle<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> repeat<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> station<span style="color: #339933;">:</span> _<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $<span style="color: #339933;">,</span> record<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>genre<span style="color: #339933;">:</span> <span style="color: #3366CC;">'comedy'</span><span style="color: #339933;">,</span> showTitle<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> repeat<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> station<span style="color: #339933;">:</span> _<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $<span style="color: #339933;">,</span> record<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>genre<span style="color: #339933;">:</span> <span style="color: #3366CC;">'crime'</span><span style="color: #339933;">,</span> showTitle<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Cops'</span><span style="color: #339933;">,</span> repeat<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> station<span style="color: #339933;">:</span> _<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $<span style="color: #339933;">,</span> record<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>genre<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> showTitle<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> repeat<span style="color: #339933;">:</span> _<span style="color: #339933;">,</span> station<span style="color: #339933;">:</span> _<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
  <span style="color: #009900;">&#41;</span>;
&nbsp;
  Object.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span>channels<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>channel<span style="color: #339933;">,</span> number<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    surf<span style="color: #009900;">&#40;</span>channel<span style="color: #339933;">,</span> number<span style="color: #009900;">&#41;</span>;
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>The last case in the pattern match is a catch-all to make the match exhaustive.</p>
<p>I&#8217;m not sure if implementing pattern matching on top of JavaScript is a good idea though. The syntax especially suffers. I&#8217;ve been thinking about moving the pattern matching into a preprocessor, but then it wouldn&#8217;t be JavaScript anymore <img src='http://leftrightfold.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The death of if-else, if, and else by Aaron Feng</title>
		<link>http://leftrightfold.com/?p=85&cpage=1#comment-1066</link>
		<dc:creator>Aaron Feng</dc:creator>
		<pubDate>Sun, 06 Dec 2009 16:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://leftrightfold.com/?p=85#comment-1066</guid>
		<description>@mike a default action can be implemented with almost no effort. Maybe I can show that, so there will be no error if genre isn't in the action table.</description>
		<content:encoded><![CDATA[<p>@mike a default action can be implemented with almost no effort. Maybe I can show that, so there will be no error if genre isn&#8217;t in the action table.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
