Nicolas Sebrecht wrote:
On Wed, Apr 29, 2009 at 03:48:51PM -0400, Bill Pemberton wrote:
Again, it prevents bugs. People use "and" vs "&&" as the same thing,
when they are not. The have different precedence in perl.
I agree with you except that the chapter 4.16 from the Perl Best
Practices book does not apply here. FMPOV, we don't really mix booleans
because the precedence is explicitly given by the parentheses.
[ Notice _how_ the author raises the ambiguity to explain his point in
the book: he uses parentheses. ]
For example,
next if not $finished || $x < 5;
next if !$finished || $x < 5;
do not mean the same thing.
True. But the lines we are talking about are different. We have:
next if ($finished or $x < 5);
If we add a "not"/"!" or append a "&&"/"and" - or whatever -, we do know what will
be evaluated easily:
next if !($finished or $x < 5);
looks rather different from
next if (!$finished or $x < 5);
I'm rather clueless when it comes to perl coding, but I know what I
don't know, so I've got enough sense to look these things up whenever
I have to hack some perl. I hope others do the same.
Personally, I've found that never using 'or', 'not' or 'and', and
overparenthesize when I'm uncertain seems to work rather nicely,
even though perl gurus would probably shunt my code as overly explicit.
--
Andreas Ericsson andreas.ericsson@xxxxxx
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
http://nordicmeetonnagios.op5.org/
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html