<div dir="ltr">On Sat, Nov 25, 2017 at 5:21 PM, Mike Kluev <span dir="ltr"><<a href="mailto:mike.kluev@gmail.com" target="_blank">mike.kluev@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="">On 25 November 2017 at 23:07, Xiaodi Wu <span dir="ltr"><<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div><div>Not sure what you’re asking. Equatable is a protocol.</div></div></span></blockquote><div><br></div></span><div>that's the point. i mean, if user writes this:</div><div><br></div><div>extension (Equatable, Equatable) : Equatable</div><div><br></div><div>what *else* could he mean other than this:</div><div><br></div><div>extension <T: Equatable, R: Equatable> (T, R) : Equatable</div></div></div></div></blockquote><div><br></div><div>No, it would mean extending the concrete type `(Equatable, Equatable)` (which has other roadblocks to becoming possible because Equatable has Self requirements).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>and if it is indeed the only reasonable meaning we can think of - i'd say the first notation is nicer.</div><span class=""><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote"><div dir="auto">For a protocol P, (P, P) is a concrete type with two elements each of existential type P. </div></div></div></blockquote><div><br></div></span><div>this part i do not understand. protocol is not an existential type. or is it?</div></div></div></div></blockquote><div><br></div><div>Ah. You seem to be unfamiliar with protocol existentials. Protocols (currently, only those without Self or associated type requirements, for various implementation reasons) are themselves types. For example, you can write:</div><div><br></div><div>```</div><div>protocol P { }</div><div>extension Int : P { }</div><div>let x: P = 42</div><div>```</div><div><br></div><div>In this example, x is of type `P`, not of type `Int`. Let's clarify the difference:</div><div><br></div><div>```</div><div>extension Array where Element == P {</div><div> func hi() {</div><div> print("Hello")</div><div> }</div><div>}</div><div><br></div><div>extension Array where Element : P {</div><div> func hi() {</div><div> print("World!")</div><div> }</div><div>}</div><div><br></div><div>let y: [P] = [x]</div><div>let z: [Int] = [x as Int]</div><div><br></div><div>y.hi() // Prints "Hello"</div><div>z.hi() // Prints "World!"</div><div>```</div><div><br></div><div>Moreover, if we do not write the first `extension Array`, then `y.hi()` doesn't compile. This helps to illustrate that P does not conform to itself.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote"><div dir="auto">For a type T : P, a tuple of type (T, T) is not a tuple of type (P, P). If we can extend tuples, you can write a generic algorithm that works with any type (T, T) where T : P, and/or you can write an algorithm that works with concrete type (P, P). Note that there is no overlap between these two because existential type P does not conform to protocol P.</div><div dir="auto"><br></div></div></div></blockquote><div><br></div></span><span class="HOEnZb"><font color="#888888"><div>Mike</div><div><br></div></font></span></div></div></div>
</blockquote></div><br></div></div>