<?xml version="1.0" encoding="windows-1252"?>
<node id="301397" title="Re: Perl Idioms Explained - &amp;&amp; and || &quot;Short Circuit&quot; operators" created="2003-10-22 18:10:29" updated="2005-07-07 15:25:06">
<type id="11">
note</type>
<author id="108447">
demerphq</author>
<data>
<field name="doctext">
&lt;!--

&lt;code&gt;&lt;/code&gt;
&lt;i&gt;&lt;/i&gt;
&lt;b&gt;&lt;/b&gt;
&amp;#91; &amp;#93; 
--&gt;
&lt;p&gt;&lt;em&gt;C-style?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
You split "C-style" and "short cicuit" into two sections. The whole point of refering to them as "C-Style" is because they &lt;i&gt;are&lt;/i&gt; "short circuit".  I believe the reason was that C is the most commonly known old school language that defines its logical operators to "short circuit".  Turbo Pascal's logical operators were short circuit, but I dont know if this is part of the Pascal language definition, or just one of many Borland extensions. OTOH, Basic generally does not have short circuit operators (and thus presumably Fortran does not have them either). However I'd guess that most modern languages have operators which short circuit considering the convenience they offer. Without them you have to write this
&lt;/p&gt;
&lt;code&gt;
if (defined $array-&gt;[1] and $array-&gt;[1] eq 'foo') {
  ...
}
&lt;/code&gt;
&lt;p&gt;
as a nested if, like this
&lt;/p&gt;
&lt;code&gt;
if (defined $array-&gt;[1]) {
  if ($array-&gt;[1] eq 'foo') {
    ...
  }
}
&lt;/code&gt;
&lt;p&gt;
which is a source of perpetual frustration to me when I have to hack on VB code. (A chore that luckily I do very rarely these days.)
&lt;/p&gt;
&lt;p&gt;
Anyway, good meditation.
&lt;/p&gt;
&lt;br /&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-108447"&gt;
---
&lt;br /&gt; 
demerphq&lt;br /&gt;
&lt;br /&gt;
&lt;sub&gt;

&lt;ol&gt;
&lt;p&gt;&lt;em&gt;First they ignore you, then they laugh at you, then they fight you, then you win. 
&lt;/em&gt;&lt;br /&gt; -- Gandhi&lt;/p&gt;
&lt;/ol&gt;
&lt;/sub&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;!--
&lt;hr /&gt;
&lt;sub&gt;
&lt;p&gt;
&lt;strong&gt;&amp;bull; Update:&amp;nbsp;&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;

&lt;/p&gt;
&lt;/sub&gt;
--&gt;
&lt;br /&gt;
</field>
<field name="root_node">
301355</field>
<field name="parent_node">
301355</field>
</data>
</node>
