Why have both bit-wise and logical operators?

Since integers don’t have an implicit logical value in Swift, and since booleans don’t have implicit integer values, why do we need separate operators for concepts that essentially seem (to me, anyway) to only differ by the “bit depth” of the types they operate on?

I normally wouldn’t raise this at a time when everyone’s so busy, but breaking changes and whatnot…

- Dave Sweeris

The logical operators short-circuit. Also, they're used in really different ways; having them be spelled differently is communicatively powerful.

John.

···

On Aug 12, 2016, at 2:57 PM, David Sweeris via swift-evolution <swift-evolution@swift.org> wrote:
Since integers don’t have an implicit logical value in Swift, and since booleans don’t have implicit integer values, why do we need separate operators for concepts that essentially seem (to me, anyway) to only differ by the “bit depth” of the types they operate on?

I normally wouldn’t raise this at a time when everyone’s so busy, but breaking changes and whatnot…

Also, bitwise operators have precedence over comparison operators. `if foo == bar && baz == frob` would have to be replaced with `if (foo == bar) & (baz == frob)`.

Félix

···

Le 12 août 2016 à 14:59:27, John McCall via swift-evolution <swift-evolution@swift.org> a écrit :

On Aug 12, 2016, at 2:57 PM, David Sweeris via swift-evolution <swift-evolution@swift.org> wrote:
Since integers don’t have an implicit logical value in Swift, and since booleans don’t have implicit integer values, why do we need separate operators for concepts that essentially seem (to me, anyway) to only differ by the “bit depth” of the types they operate on?

I normally wouldn’t raise this at a time when everyone’s so busy, but breaking changes and whatnot…

The logical operators short-circuit. Also, they're used in really different ways; having them be spelled differently is communicatively powerful.

John.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution