> On Aug 2, 2016, at 12:18 AM, Félix Cloutier via swift-evolution
> <[email protected]> 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".
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution