<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 24, 2016, at 9:35 PM, Austin Zheng <<a href="mailto:austinzheng@gmail.com">austinzheng@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 4:24 PM, Brent Royal-Gordon <span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> I’m not sure what you mean about introducing type unsafely.<br>
<br>
</span>What I mean is that once you do this:<br>
<br>
let x: AnyCollection<Character> = myArrayOfCharacters<br>
let y: AnyCollection<Character> = myString.characters<br>
<br>
Both `x` and `y` have indices of type `Any<Comparable>`, and will now accept each others' indices:<br>
<br>
for i in x.indices {<br>
print(y[i]) // Oops!<br>
}<br>
<br>
If this rule:<br>
<span class=""><br>
> 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.<br>
<br>
</span>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.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>If there's any way that the rules that I've proposed can be relaxed without sacrificing type safety, I would love to hear it. I think the difference in 'power' in this regard between a function that uses generic types and a function that uses existentials is something inherent to how each works, though.</div></div></div></div></div></blockquote><div><br></div><div>The primary difference is the freedom to accept an index which is invalid and call fatalError when you get it. We don't want existentials to do something that. But with user-defined types we have the flexibility to do that if we decide it is the right design.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
</font></span></blockquote></div><br></div></div>
</div></blockquote></body></html>