develooper Front page | perl.perl6.language | Postings from June 2009

Re: XOR does not work that way.

Thread Previous | Thread Next
From:
Darren Duncan
Date:
June 22, 2009 18:57
Subject:
Re: XOR does not work that way.
Message ID:
4A40366A.80701@darrenduncan.net
Mark J. Reed wrote:
> All of which is just by way of agreeing with Jon: formal logic is not
> the primary motivator behind Perl's design. So while it should be
> considered, it's not a knockout punch to say "but logic doesn't work
> that way."

I think another thing to consider is a survey of the various other common 
languages and see what semantics they have with an expression like this pseudocode:

   true xor true xor true

I would like to know in what languages the above expression is false ... or true.

I suggest that to aid learnability, Perl 6 has the same semantics for 'xor' as 
other languages with that operator, unless there is a good explicit reason to do 
differently; that is, don't do differently just for the heck of it.

I submit that Perl 5 appears to result in true, as tested with:

   perl -e "print (5 xor 2 xor 3)"

... which returns 1, indicating also that Perl 5 xor doesn't short-circuit.

Regardless of the above, I think Perl 6 should have both operators, testing 
exactly 1 or an odd number.

-- Darren Duncan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About