in reply to Re: Re: Implication operator
in thread Implication operator
I don't really share your feelings about 'xor' precedence. Two situations where its precedence allows you to forego parenthesis:
In the first example, would you rather xor's precedence be higher than ||? Now look at what we have to do:if ($a || $b xor $c || $d) { ... } if ($a xor $b) { ... }
If we want to do swap the xor/|| operators, I can possibly see the advantage, but really any complex situation like this is going to almost require you to use paranthesis in order to show Perl how you want things evaluated. Perhaps you are confusing 'xor' with the bitwise/integer xor operator (^), which has a much higher precedence. See perlop.if (($a || $b) xor ($c || $d)) { ... }
Realistically (and I don't know why I didn't mention this before), this should probably be used in expressions instead of 'xor', unless you need something that's low precedence (like using 'or' or 'and' in expressions).if ($a ^ $b || $c ^ $d) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Implication operator
by chipmunk (Parson) on Dec 11, 2000 at 21:52 UTC | |
by Fastolfe (Vicar) on Dec 11, 2000 at 23:56 UTC |