[swift-evolution] [Pre-proposal] Replace [Foo] With CollectionType

Brent Royal-Gordon brent at architechies.com
Tue May 24 18:24:44 CDT 2016


> I’m not sure what you mean about introducing type unsafely.

What I mean is that once you do this:

	let x: AnyCollection<Character> = myArrayOfCharacters
	let y: AnyCollection<Character> = myString.characters

Both `x` and `y` have indices of type `Any<Comparable>`, and will now accept each others' indices:

	for i in x.indices {
		print(y[i])		// Oops!
	}

If this rule:

> The generalized existentials proposal goes out of its way to be explicit about the fact that only type safe operations would be visible through the existential.

Is trying to say that this isn't the case because APIs using the collection's `Index` are not exposed on an `AnyCollection`, well, then I'm not sure what `AnyCollection` is actually supposed to be used for.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list