<?xml version="1.0" encoding="windows-1252"?>
<node id="301689" title="Re: Re: Re: Re: Re: Perl Idioms Explained: &amp;&amp; and || &quot;Short Circuit&quot; operators" created="2003-10-23 15:46:48" updated="2005-07-08 13:04:31">
<type id="11">
note</type>
<author id="171588">
BrowserUk</author>
<data>
<field name="doctext">
&lt;p&gt;I look forward to the power of the P6 Given/When construct immensely, but I still hanker for the the limited but oh-so-useful and efficient switch/case construct. There are so many occasions when this simple integer-based dispatch mechanism is exactly all that is needed, that I think it would be worth having, in addition to the much more powerful, but equally, much less efficient Given/When construct.

&lt;p&gt;I'm aware of [theDamian]'s [cpan://switch] module, but it attempts to be much more than a simple switch construct, coming much closer to the given/when flexibility. The downside of that it that it is much less efficient for the predominant 'simple case'. I've also had problems with it getting confused.

&lt;p&gt;Hash based dispatch tables are okay and pretty efficient, but the need to put the selected code into either a sub or runtime [eval] makes it less useful for things where the selected code is minimal and speed important. Calling a sub to increment or decrement a count is high overhead if your scanning long strings and maintaining counts as you go.


&lt;div class="pmsig"&gt;&lt;div class="pmsig-171588"&gt;
&lt;/div&gt;&lt;/div&gt;&lt;hr /&gt;
&lt;font size=1 &gt;
&lt;div&gt;Examine what is said, not who speaks.&lt;/div&gt;
"Efficiency is intelligent laziness." -David Dunham&lt;br /&gt;
"Think for yourself!" - [Abigail-II|Abigail] &lt;br /&gt;
[http://news.bbc.co.uk/1/hi/technology/3181108.stm|Hooray!]&lt;br /&gt;
&lt;/p&gt;&lt;/font&gt;

&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
301355</field>
<field name="parent_node">
301588</field>
</data>
</node>
