Completely forgot about those. Thank you. The point still stands, it doesn't 
really make sense to multiply strides by each other. I don't know how this 
would work, but if we're already ok to shake up the Integer protocols, then 
maybe adding one between SignedNumeric and SignedInteger might be ok.


> On 31 Mar 2017, at 17:25, Xiaodi Wu <[email protected]> wrote:
> 
> Have you seen the revised integer protocols?
> https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
>  
> <https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md>
> 
> `SignedNumeric` will no longer refine `Comparable`. It will, however, still 
> require that you can define multiplication.
> 
> 
> On Fri, Mar 31, 2017 at 11:09 AM, Sasha Lopoukhine via swift-evolution 
> <[email protected] <mailto:[email protected]>> wrote:
> Hello everyone!
> 
> I'd like to discuss the constraint on Strideable. I see no reason to restrict 
> Strideable types to non-circular types. It would be pretty neat/useful to be 
> able to define a type such as a Week, with strides looping around to the 
> start of the enum. Currently, the only reason this is impossible is because 
> of the restriction on Stride that it must conform to SignedNumber.
> 
> I think that it might be worth looking into defining a new protocol 
> specifically for the constraint on Strideable.Stride, something that looks 
> like this:
> 
> /// Instances of conforming types can be subtracted, arithmetically
> /// negated, and initialized from `0`.
> ///
> /// Axioms:
> ///
> /// - `x - 0 == x`
> /// - `-x == 0 - x`
> /// - `-(-x) == x`
> public protocol StrideProtocol : ExpressibleByIntegerLiteral {
> 
>     /// Returns the result of negating `x`.
>     prefix public static func -(x: Self) -> Self
> 
>     /// Returns the difference between `lhs` and `rhs`.
>     public static func -(lhs: Self, rhs: Self) -> Self
> }
> 
> public typealias SignedNumber = StrideProtocol & Comparable
> 
> Strideable.Stride could then conform to StrideProtocol, allowing groups etc. 
> 
> WDYT?
> 
> -- Sasha
> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to