in reply to Anyone use "xor" in conditionals?
specially when either condition is either expensive, or has side-effects.if ((COND1 || COND2) && !(COND1 && COND2))
A while ago, I was writing a small script that recursively compared directories (and no, plain diff didn't do, although the script called diff repeatedly). Since I was interested in the similarities instead of the differences, at one moment I wrote:
next if -d $dir1 xor -d $dir2
If either of the arguments wasn't a directory, but the other was, they couldn't match. But if both were, or both weren't, furthermore analysis was necessary.
And yes, I know, xor can be written using other primitives as well. But that's not an argument, unless you also think 'for', 'while' and other looping constructs are redundant, because we have 'goto'.
Abigail
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Anyone use "xor" in conditionals?
by Excalibor (Pilgrim) on Jul 14, 2003 at 09:52 UTC | |
by Abigail-II (Bishop) on Jul 14, 2003 at 11:07 UTC | |
by Excalibor (Pilgrim) on Jul 14, 2003 at 14:27 UTC | |
by sauoq (Abbot) on Jul 14, 2003 at 17:05 UTC | |
by Excalibor (Pilgrim) on Jul 14, 2003 at 19:08 UTC | |
by exussum0 (Vicar) on Jul 14, 2003 at 16:29 UTC | |
by Excalibor (Pilgrim) on Jul 14, 2003 at 17:08 UTC | |
Re: Re: Anyone use "xor" in conditionals?
by BUU (Prior) on Jul 14, 2003 at 04:29 UTC | |
by Abigail-II (Bishop) on Jul 14, 2003 at 06:11 UTC | |
|