[swift-evolution] [Review] SE-0104: Protocol-oriented integers

Max Moiseev moiseev at apple.com
Thu Jun 23 13:29:18 CDT 2016


Hi David,

> In addition to the technical review, I would like to point out that the definition of Arithmetic appears to be missing some underscores in add/adding/subtract/subtracting

Thank you! I’ll fix it.

> For Integer, does the presence of signBit indicate an expectation that signed Integers will have a two's complement representation?
Yes. That is correct.

> For FixedWidthInteger#dividedWithOverflow/remainderWithOverflow, under what situations would you have an overflow? I could only come up with something like Int.min.dividedWithOverflow(-1).
If you look at the prototype here: https://github.com/apple/swift/blob/master/test/Prototypes/Integers.swift.gyb#L789 there is exactly the check that you’ve mentioned, but for all signed integers. Besides, it is very convenient to have all the arithmetic operations be implemented the same way, even if there were no real overflows for division.

Max


> On Jun 22, 2016, at 10:42 PM, David Waite via swift-evolution <swift-evolution at swift.org> wrote:
> 
> In addition to the technical review, I would like to point out that the definition of Arithmetic appears to be missing some underscores in add/adding/subtract/subtracting
>> 
>> 	https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
>> 
>> 	* What is your evaluation of the proposal?
> 
> I’m so glad this work is being done!
> 
> For Integer, does the presence of signBit indicate an expectation that signed Integers will have a two's complement representation?
> 
> For FixedWidthInteger#dividedWithOverflow/remainderWithOverflow, under what situations would you have an overflow? I could only come up with something like Int.min.dividedWithOverflow(-1).
> 
>> 	* Is the problem being addressed significant enough to warrant a change to Swift?
> 
> Yes, oh yes.
> 
>> 	* Does this proposal fit well with the feel and direction of Swift?
> 
> It looks like a significant improvement. 
> 
>> 
>> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> I combed the proposal for questions, although most were answered by the time I hit the end.
> 
> -DW
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list