On Tuesday 12 April 2005 19:18, Andrew Savige wrote:
> It does. At least according to "Perl 6 and Parrot Essentials" book,
> page 36 it does (I couldn't find details on xor operator in S03).
> I added some xor tests which Autrijus fixed. I'm worried now that
> my tests may be wrong. On page 36 it says: "it returns the value
> of the true operand if any one operand is true".

The mathematical definition of xor for two arguments is "true if
exactly one argument is true, false otherwise".  When that gets
generalized to multiple arguments it means "true if an odd number
of the arguments are true, false otherwise".  So, you cannot short
circuit the evaluation because any value, if it happens to be true,
changes the result of the expression.  However, with perl's usual
flexibility for the value "true" you could choose the first or last true
value as the result if there were an odd number of true values, I
suppose, but returning last true (or false) makes more sense.
(Using the first is essentially the same as making xor right associative
instead of left.)

Reply via email to