You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by DeWitt Clinton <de...@eziba.com> on 2000/02/24 17:38:50 UTC
Re: [OT] Perl question...
On Thu, Feb 24, 2000 at 05:31:57PM +0100, Victor Zamouline wrote:
> > As more readable alternatives to &&, ||, and !, Perl provides the and, or
> > and not operators. The behavior of these operators _IS IDENTICAL_ - in
> > particular, they short-circuit the same way.
>
> I guess their _behavior_ is identical but their _precedence_ is not the
> same.
Right. And those operators were not created as a more readable
alternative. They were created *because* their precedence is
different. The "and," "or," and "not" operators are supposed to be
lower in precendence so that you can say things like:
my $foo = $bar || $default or
die("Couldn't set foo");
Of course, this is just silly, and you should use parentheses!
-DeWitt
Re: [OT] Perl question...
Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "DeWitt" == DeWitt Clinton <de...@eziba.com> writes:
DeWitt> Right. And those operators were not created as a more readable
DeWitt> alternative. They were created *because* their precedence is
DeWitt> different.
Well, the "xor" operator didn't have a trivial punctuation equivalent,
so there's actually added functionality. Yeah, you can do something like:
!(EXPRESSION_A) != !(EXPRESSION_B)
But that's just messy, when you can do this instead:
EXPRESSION_A xor EXPRESSION_B
DeWitt> Of course, this is just silly, and you should use parentheses!
If you want to use LISP, you know where to find it. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!