[swift-evolution] protocol-oriented integers (take 2)

Stephen Canon scanon at apple.com
Mon Jan 16 12:02:41 CST 2017

> On Jan 16, 2017, at 3:25 AM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> Unless I'm mistaken, after removing division, models of SignedArithmetic would have the mathematical properties of a ring. For every element a in ring R, there must exist an additive inverse -a in R such that a + (-a) = 0. Models of Arithmetic alone would not necessarily have that property.

Closure under the arithmetic operations is a sticky point for all the finite integer models vs. the actual ring axioms.  No finite [non-modulo] integer type is closed, because of overflow. Similarly, additive inverses don’t exist for the most negative value of a signed type, or for any non-zero value of an unsigned type. The obvious way around this is to say that types conforming to Arithmetic model a subset of a ring that need not be closed under the operations.

– Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170116/860968a4/attachment.html>

More information about the swift-evolution mailing list