On Sat, May 07, 2005 at 02:04:45AM +0200, Juerd wrote:
: Juerd skribis 2005-05-07  1:23 (+0200):
: > Perl 5's perlop says: "It cannot short circuit, of course." Can
: > someone explain why it cannot?
: 
: I was confused. It is entirely obvious why it can't.

On the other hand, one(...) semantics can short circuit false as
soon as you find two trues, except that one(...) is not guaranteed
to execute in any particular order, whereas I think xor and ^^
should be make list associative but execute left-to-right, short
circuiting on the second true discovered, so you have some hope of
ordering the harder conditions later in a sequence and bypassing them.
In either case the one true value is returned.  This seems to me to
be the most useful semantics.  Presumably one could also get ordered
tests like this:

    $trueone = infix:<xor> map { $_ = '' unless /foo/ } =$fh;

and return the one line in $fh that contains "foo", bombing out immediately
if there are two such lines.  (I'm assuming infix:<xor> can be called
as a list operator there...)

Parity XOR is fine for +^, ~^, and even ?^, of course.

Larry

Reply via email to