Just a simple [cpan.org] guy, hacking Perl for fun and profit since way back in the last millenium. You may find me hanging around in the monestary [perlmonks.org].
What am I working on right now? Probably the Sprog project [sourceforge.net].
GnuPG key Fingerprint:
6CA8 2022 5006 70E9 2D66
AE3F 1AF1 A20A 4CC0 0851
From our production codebase:
unless (not condition1 xor (condition2 or condition3)) {
I think most of us would at least have to slow down to extract the essential meaning of that line.
The only saving grace of this piece of code was that condition1, condition2 and condition3 were all named boolean scalars.
I miss xor :( (Score:1)
It was such a staple in my assembler days and now I can’t remember the last time I used it.
Anyway, you can easily decomplexify that condition:
We start here:
unless ( not $condition1 xor ( $condition2 or $condition3 ) )unlessshould be reserved for trivial conditions:if ( not( not $condition1 xor ( $condition2 or $condition3 ) ) )The properties of xor mean that not(a xor b) trivially distributes as not(a) xor not(b):
if ( not( not $condition1 ) xor not( $condition2 or $condition3 ) )Re:I miss xor :( (Score:1)
You are wrong here. Take for instance the case where a and b are both false. Then a xor b is false, and hence, not (a xor b) is true. However, both not(a) and not(b) are true, and hence, not(a) xor not(b) is false.
(a xor b) is equal to not (a) xor not (b). not (a xor b) is equal to not (a) xor b, or a xor not (b).
Which means that the original case could have been written as:
Re:I miss xor :( (Score:1)
Aaarrrgh.
Thanks for the correction; that’s what happens when you can’t remember when you used something the last time…