<div class="gmail_quote">On Wed, Dec 23, 2009 at 3:27 PM, Joseph Werner <span dir="ltr">&lt;<a href="mailto:telcodev@gmail.com">telcodev@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Dec 23, 2009 at 2:52 PM, Skylos &lt;<a href="mailto:skylos@gmail.com">skylos@gmail.com</a>&gt; wrote:<br>
&gt; ...<br>
<div class="im">&gt; Which makes me think &quot;something about that value when a shift is done uses<br>
&gt; the value in a boolean context&quot;<br>
</div>&gt; ...<br>
<br>
Thanks for the feedback Skylos, This is exactly the same conclusion<br>
that we have come too; but I STILL cannot place a boolean context in<br>
the a simple shift assignment. The powers that be crack the whip and<br>
say &quot;Problem solved, move on&quot;.   Code that does not behave the way I<br>
expect it to bothers me...<br>
<br></blockquote><div><br>I was considering that shift had an implicit boolean context as well so
did some digging.  Based on my test implementation it appears that
shift doesn&#39;t have an implicit boolean context.  Perhaps the boolean context is occuring after the $choosenO is returned?<br><br>Here&#39;s my test script <a href="http://is_shift_boolean.pl">is_shift_boolean.pl</a>:<br>
      1 #!/usr/bin/perl<br>      2<br>      3 use strict;<br>      4 use warnings;<br>      5 use Carp;<br>      6<br>      7 my @objects = map{Snoop-&gt;new()} 1..3;<br>      8<br>      9 # Implicit boolean context here?<br>
     10 my $first = shift @objects;<br>     11<br>     12 # explicit boolean context here<br>     13 if ($first) {<br>     14   # nothing to do here.<br>     15 }<br>     16<br>     17 package Snoop;<br>     18<br>     19 use overload (<br>
     20   q{bool} =&gt; sub {<br>     21         my $self = shift;<br>     22         Carp::confess(&quot;Boolean context on objnum $self-&gt;{objnum}&quot;);<br>     23         return $self;<br>     24       },<br>     25 );<br>
     26<br>     27 my $objnum = 0;<br>     28<br>     29 sub new {<br>     30   my $class = shift;<br>     31   return bless {objnum =&gt; $objnum++}, $class;<br>     32 }<br>     33 __END__<br><br>This uses the overload pragma to do the operator overloading so if you&#39;re using something else the results may be different.<br>
<br>Upon execution I got the following output:<br>Boolean context on objnum 0 at <a href="http://is_shift_boolean.pl">is_shift_boolean.pl</a> line 22<br>        Snoop::__ANON__(&#39;Snoop=HASH(0x814ccd4)&#39;, &#39;undef&#39;, &#39;&#39;) called at <a href="http://is_shift_boolean.pl">is_shift_boolean.pl</a> line 13<br>
<br>This reports only one boolean context in the if statement at line 13.  There is no report of boolean context from line 10 where the shift is.<br><br>A mystery for the ages,<br><br>-- <br>Ben<br></div></div>