[Accepted] SE-0104: Protocol-oriented integers

Proposal link: swift-evolution/0104-improved-integers.md at master · apple/swift-evolution · GitHub

Hello Swift Community,

The review of "SE-0104: Protocol-oriented integers" ran from June 22...27. The proposal is *accepted* for Swift 3 with revisions:

The feedback from the community was very positive and contributed a number of improvements to the design of the proposal. The core team has accepted the proposal, subject to the following changes:

- The “Integer" protocol should be renamed to “BinaryInteger” to be more accurate and avoid confusion between “Int" and “Integer”.
- The “FloatingPoint" protocol should conform to the “Arithmetic” protocol.
- Rename the “absoluteValue” property to “magnitude”, and sink it down to the “Arithmetic” protocol.
- Eliminate the “AbsoluteValuable" protocol, since “abs” can now be defined in terms of “Arithmetic".
- Rename the “signBitIndex" property to "minimumSignedRepresentationBitWidth".
- Add a “popcount" property requirement to the “FixedWidthInteger” protocol.
- Change the "countLeadingZeros()" member of concrete types to be a “leadingZeros” property on “FixedWidthInteger”.
- Rename "func nthWord(n: Int) -> UInt” to "func word(at: Int) -> UInt”.
- Rename the “and”, “or”, and “xor” members of “FixedWidthInteger” to “bitwiseAnd”, “bitwiseOr” and “bitwiseXor”.
- Change “doubleWidthMultiply” to be a static member, and add a “doubleWidthDivide” member as its dual. The latter will return both quotient and remainder of type “Self". Both are to be added to the "FixedWidthInteger" protocol.

Many thanks to Maxim Moiseev, Dave Abrahams and Dmitri Gribenko for driving this proposal forward, Steve Canon for his important input, and to Maxim Moiseev for driving the implementation work forward.

-Chris Lattner
Review Manager

I’m glad this was approved, the improvements look substantial!

My one question is why are the bitwise operations (and/or/xor) modeled as
member functions rather than operators?

···

On Thursday, June 30, 2016, Chris Lattner via swift-evolution < swift-evolution@swift.org> wrote:

Proposal link:
https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md

Hello Swift Community,

The review of "SE-0104: Protocol-oriented integers" ran from June 22...27.
The proposal is *accepted* for Swift 3 with revisions:

The feedback from the community was very positive and contributed a number
of improvements to the design of the proposal. The core team has accepted
the proposal, subject to the following changes:

- The “Integer" protocol should be renamed to “BinaryInteger” to be more
accurate and avoid confusion between “Int" and “Integer”.
- The “FloatingPoint" protocol should conform to the “Arithmetic”
protocol.
- Rename the “absoluteValue” property to “magnitude”, and sink it down to
the “Arithmetic” protocol.
- Eliminate the “AbsoluteValuable" protocol, since “abs” can now be
defined in terms of “Arithmetic".
- Rename the “signBitIndex" property to
"minimumSignedRepresentationBitWidth".
- Add a “popcount" property requirement to the “FixedWidthInteger”
protocol.
- Change the "countLeadingZeros()" member of concrete types to be a
“leadingZeros” property on “FixedWidthInteger”.
- Rename "func nthWord(n: Int) -> UInt” to "func word(at: Int) -> UInt”.
- Rename the “and”, “or”, and “xor” members of “FixedWidthInteger” to
“bitwiseAnd”, “bitwiseOr” and “bitwiseXor”.
- Change “doubleWidthMultiply” to be a static member, and add a
“doubleWidthDivide” member as its dual. The latter will return both
quotient and remainder of type “Self". Both are to be added to the
"FixedWidthInteger" protocol.

Many thanks to Maxim Moiseev, Dave Abrahams and Dmitri Gribenko for
driving this proposal forward, Steve Canon for his important input, and to
Maxim Moiseev for driving the implementation work forward.

-Chris Lattner
Review Manager

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <javascript:;>
https://lists.swift.org/mailman/listinfo/swift-evolution

My understanding is that we're trying to avoid directly declaring operator overloads as this pollutes the global namespace and makes operator function lookup slower compared to finding a named function in a named type.

Félix

···

Le 2 juil. 2016 à 05:02:20, Nevin Brackett-Rozinsky via swift-evolution <swift-evolution@swift.org> a écrit :

I’m glad this was approved, the improvements look substantial!

My one question is why are the bitwise operations (and/or/xor) modeled as member functions rather than operators?

On Thursday, June 30, 2016, Chris Lattner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Proposal link: https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md

Hello Swift Community,

The review of "SE-0104: Protocol-oriented integers" ran from June 22...27. The proposal is *accepted* for Swift 3 with revisions:

The feedback from the community was very positive and contributed a number of improvements to the design of the proposal. The core team has accepted the proposal, subject to the following changes:

- The “Integer" protocol should be renamed to “BinaryInteger” to be more accurate and avoid confusion between “Int" and “Integer”.
- The “FloatingPoint" protocol should conform to the “Arithmetic” protocol.
- Rename the “absoluteValue” property to “magnitude”, and sink it down to the “Arithmetic” protocol.
- Eliminate the “AbsoluteValuable" protocol, since “abs” can now be defined in terms of “Arithmetic".
- Rename the “signBitIndex" property to "minimumSignedRepresentationBitWidth".
- Add a “popcount" property requirement to the “FixedWidthInteger” protocol.
- Change the "countLeadingZeros()" member of concrete types to be a “leadingZeros” property on “FixedWidthInteger”.
- Rename "func nthWord(n: Int) -> UInt” to "func word(at: Int) -> UInt”.
- Rename the “and”, “or”, and “xor” members of “FixedWidthInteger” to “bitwiseAnd”, “bitwiseOr” and “bitwiseXor”.
- Change “doubleWidthMultiply” to be a static member, and add a “doubleWidthDivide” member as its dual. The latter will return both quotient and remainder of type “Self". Both are to be added to the "FixedWidthInteger" protocol.

Many thanks to Maxim Moiseev, Dave Abrahams and Dmitri Gribenko for driving this proposal forward, Steve Canon for his important input, and to Maxim Moiseev for driving the implementation work forward.

-Chris Lattner
Review Manager

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <javascript:;>
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution