develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #59802] return 0 or die;

Miles Gould
May 1, 2013 17:58
Re: [perl #59802] return 0 or die;
Message ID:
On 19 Feb 2013 at 17:07:05, Jan Dubois wrote:
 > Just for the record, I've also seen
 > return foo() and bar(); # supposed to return TRUE only when
 > both foo() and bar() are true

I ran into this problem last night. The offending line was

return ($self->true_count($idx) > 0) xor ($self->false_count($idx) > 0);

and in this case it's easy to explain what I had in mind: I wanted my 
function to return the logical xor of those two expressions! Once I'd 
tracked the problem down it was easy enough to fix by reparenthesising, 
but a warning would have been very useful.

Miles Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About