[swift-evolution] [Idea] Generic subscripts

Brent Royal-Gordon brent at architechies.com
Wed Aug 3 04:16:18 CDT 2016

> On Aug 3, 2016, at 1:57 AM, Tino Heth <2th at gmx.de> wrote:
>> Since RangeExpression is a protocol compatible with any index type, it has to have an associated type
> I haven't read all linked information, but would the situation change with generic protocols?
> Thinks like "AnyGenerator" afaics would be superfluous if we had "protocol Generator<Type>", and the same might be true for RangeExpression.

No, this is not an appropriate use case for generic protocols. (Nor is Generator/IteratorProtocol, for that matter.)

Generic protocols would be for cases where a single concrete instance can conform to a protocol using several different types. Genuine use cases for that do exist, but they're few and far between.

Brent Royal-Gordon

More information about the swift-evolution mailing list