[swift-evolution] [Completing Generics] Arbitrary requirements in protocols

Maximilian Hünenberger m.huenenberger at me.com
Tue Apr 12 11:35:15 CDT 2016

Hi Jacob,

I really like the idea of constraining associated types. However I think there could be a much more general solution to this problem by introducing "Partially constrained protocols".

I've already created a (almost finished) proposal for another thread which hasn't continued. It attacks the same issue as "Arbitrary requirements in protocols": https://github.com/Qbyte248/swift-evolution/blob/master/proposals/0000-Partially%20constrained%20protocols%20and%20generic%20types.md

Unfortunately I have (almost) no time to discuss this in depth or completely finish the proposal. So feel free to copy my proposal add yourself as coauthor and start a new thread. Or just take it as an inspiration :)

Kind regards
- Maximilian

PS: Looking forward to a new generics model :)

> Am 11.04.2016 um 10:01 schrieb Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org>:
> Doug wrote this in the Completing Generics manifesto, under "Minor extensions":
>> *Arbitrary requirements in protocols
>> Currently, a new protocol can inherit from other protocols, introduce new associated types, and add new conformance constraints to associated types (by redeclaring an associated type from an inherited protocol). However, one cannot express more general constraints. Building on the example from “Recursive protocol constraints”, we really want the element type of a Sequence’s SubSequence to be the same as the element type of the Sequence, e.g.,
>>     protocol Sequence {
>>         associatedtype Iterator : IteratorProtocol
>>>>         associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element
>>     }
> +1.
> To make it into Swift 3, would this feature require a proposal of its own? How feasible would it be to implement on top of the current system?
> Jacob
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160412/4b54f2bc/attachment.html>

More information about the swift-evolution mailing list