# [swift-evolution] [Discussion] Breaking precedence

Stephen Canon scanon at apple.com
Tue Aug 2 10:07:53 CDT 2016

```> On Aug 2, 2016, at 12:18 AM, Félix Cloutier via swift-evolution <swift-evolution at swift.org> wrote:
>
> I disagree. The binary operators have properties that are comparable to arithmetic operators, and their precedence is easy to define as such. & has multiplication-like properties (0*0=0, 0*1=0, 1*0=0, 1*1=1); | has addition-like properties (0+0=0, 0+1=1, 1+0=1, 1+1=2); ^ has subtraction-like properties (0-0=0, 0-1=-1, 1-0=1, 1-1=0), and their precedences are set accordingly (& is multiplicative, | and ^ are additive).

<extreme pedantry>
`^` is actually the *addition* operator on Boolean rings[1].  `x | y` corresponds to the Boolean ring operation `x + y + xy`, which is definitely “addition-like” but isn’t addition.
</extreme pedantry>

Otherwise, spot on.

– Steve

[1] Of course, it’s *also* the subtraction operator, because `x = -x` for all members `x` of a Boolean ring (https://en.wikipedia.org/wiki/Boolean_ring <https://en.wikipedia.org/wiki/Boolean_ring>), but one usually calls it “addition".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160802/be112374/attachment.html>
```