<div dir="ltr">>if our protocol conforms to a protocol with associated type requirements, then we still can't conform to our protocol multiple times.<div><br></div><div>I don't think so:</div><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="font-variant-ligatures: no-common-ligatures;">protocol</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(209,216,124)">A</span><span style="color:rgb(183,196,209)"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="color:rgb(183,196,209)"> </span><span style="font-variant-ligatures: no-common-ligatures;">associatedtype</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(220,167,124)">TypeA</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209);min-height:13px"><span style="font-variant-ligatures: no-common-ligatures;"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="font-variant-ligatures: no-common-ligatures;">protocol</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(121,216,219)">B</span><span style="color:rgb(183,196,209)"><</span><span style="color:rgb(120,216,158)">TypeB</span><span style="color:rgb(183,196,209)">>: </span><span style="color:rgb(124,175,194)">A</span><span style="color:rgb(183,196,209)"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(194,161,187)">func</span><span style="font-variant-ligatures: no-common-ligatures;"> convert(from: </span><span style="color:rgb(124,175,194)">TypeB</span><span style="font-variant-ligatures: no-common-ligatures;">) -> </span><span style="color:rgb(220,167,124)">TypeA</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209);min-height:13px"><span style="font-variant-ligatures: no-common-ligatures;"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="font-variant-ligatures: no-common-ligatures;">struct</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(120,216,160)">C</span><span style="color:rgb(183,196,209)">: </span><span style="color:rgb(124,175,194)">A</span><span style="color:rgb(183,196,209)"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="color:rgb(183,196,209)"> </span><span style="font-variant-ligatures: no-common-ligatures;">typealias</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(220,167,124)">TypeA</span><span style="color:rgb(183,196,209)"> = </span><span style="color:rgb(124,175,194)">String</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="font-variant-ligatures: no-common-ligatures;">extension</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(178,200,157)">C</span><span style="color:rgb(183,196,209)">: </span><span style="color:rgb(124,175,194)">B</span><span style="color:rgb(183,196,209)"><</span><span style="color:rgb(124,175,194)">Int</span><span style="color:rgb(183,196,209)">> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(194,161,187)">func</span><span style="font-variant-ligatures: no-common-ligatures;"> convert(from int: </span><span style="color:rgb(124,175,194)">Int</span><span style="font-variant-ligatures: no-common-ligatures;">) -> </span><span style="color:rgb(124,175,194)">String</span><span style="font-variant-ligatures: no-common-ligatures;"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(194,161,187)">return</span><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(124,175,194)">String</span><span style="font-variant-ligatures: no-common-ligatures;">(</span><span style="color:rgb(121,209,219)">int</span><span style="font-variant-ligatures: no-common-ligatures;">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(194,161,187)"><span style="font-variant-ligatures: no-common-ligatures;">extension</span><span style="color:rgb(183,196,209)"> </span><span style="color:rgb(178,200,157)">C</span><span style="color:rgb(183,196,209)">: </span><span style="color:rgb(124,175,194)">B</span><span style="color:rgb(183,196,209)"><</span><span style="color:rgb(124,175,194)">Double</span><span style="color:rgb(183,196,209)">> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(194,161,187)">func</span><span style="font-variant-ligatures: no-common-ligatures;"> convert(from double: </span><span style="color:rgb(124,175,194)">Double</span><span style="font-variant-ligatures: no-common-ligatures;">) -> </span><span style="color:rgb(124,175,194)">String</span><span style="font-variant-ligatures: no-common-ligatures;"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(194,161,187)">return</span><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="color:rgb(124,175,194)">String</span><span style="font-variant-ligatures: no-common-ligatures;">(</span><span style="color:rgb(220,129,173)">double</span><span style="font-variant-ligatures: no-common-ligatures;">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;"> }</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(183,196,209)"><span style="font-variant-ligatures: no-common-ligatures;">}</span></p><div><br></div></div><div>Seems to me like the above should work fine: the associated type is declared once, but the generic protocol is conformed to multiple times.</div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Jun 12, 2016 at 1:22 PM Антон Жилин <<a href="mailto:antonyzhilin@gmail.com">antonyzhilin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Copy of link to the proposal:</div><div><a href="https://github.com/Anton3/swift-evolution/blob/generic-protocols/proposals/NNNN-generic-protocols.md" target="_blank">https://github.com/Anton3/swift-evolution/blob/generic-protocols/proposals/NNNN-generic-protocols.md</a></div><div><br></div><div>Inline:<br></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-06-12 21:51 GMT+03:00 Dan Appel <span dir="ltr"><<a href="mailto:dan.appel00@gmail.com" target="_blank">dan.appel00@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Awesome that you guys started this! I've been meaning to pitch it for a while. Couple notes:<br><br>- in the motivation, you're conforming to SequenceType while defining a From protocol (just a typo I think)<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Fixed</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">- the proposal should mention Brent's comments since it doesn't have a rebuttal to the "unlikely" status generic protocols were given in the generic manifesto. Brent does a great job of doing that<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Added a bold link</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">- is there a way for generic protocols to still have associated types? I think that could have some interesting use cases.<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Generic protocols can contain associated types, but no type can conform to multiple instances of such protocols.</div><div><br></div><div>Actually, this limitation is more restricting than it seems, because if our protocol conforms to a protocol with associated type requirements, then we still can't conform to our protocol multiple times.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Dan Appel<div><div><br><div class="gmail_quote"></div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_quote"><div dir="ltr">On Sun, Jun 12, 2016 at 11:28 AM Антон Жилин <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div></div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Yes, everything that works on generic types should work for generic protocols. I'll add that.<div><div><br><div>What won't work is declaring that MyComparable : Comparable iff T == Self. The same won't work for current non-generic protocols as well.</div><div>Although that feature is highly requested, it is discussed in a separate proposal.</div></div><div><br></div><div>- Anton</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-12 21:16 GMT+03:00 Xiaodi Wu <span dir="ltr"><<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Sun, Jun 12, 2016 at 8:01 AM, Антон Жилин <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I've prepared a proper draft:<div><br><div><div><a href="https://github.com/Anton3/swift-evolution/blob/generic-protocols/proposals/NNNN-generic-protocols.md" target="_blank">https://github.com/Anton3/swift-evolution/blob/generic-protocols/proposals/NNNN-generic-protocols.md</a><br></div></div></div><div><br></div></div></blockquote><div><br></div></span><div>When you propose this:</div><div><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;font-size:1.5em;color:rgb(51,51,51);font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"">Syntax in protocol extensions</h3><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:16px"><pre style="font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;border-radius:3px;background-color:rgb(247,247,247)"><span style="color:rgb(167,29,93)">protocol</span> MyComparable<span style="color:rgb(167,29,93)"><</span>T<span style="color:rgb(167,29,93)">></span> {
<span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)"><</span> (<span style="color:rgb(167,29,93)">left</span>: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(167,29,93)">right</span>: T)
}
<span style="color:rgb(167,29,93)">extension</span> MyComparable {
<span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">></span> (<span style="color:rgb(167,29,93)">left</span>: T, <span style="color:rgb(167,29,93)">right</span>: <span style="color:rgb(167,29,93)">Self</span>) {
<span style="color:rgb(167,29,93)">return</span> <span style="color:rgb(167,29,93)">right</span> <span style="color:rgb(167,29,93)"><</span> <span style="color:rgb(167,29,93)">left</span>
}
}</pre></div></div><div> </div><div>Would it be possible for me to write something like:</div><div><br></div><div>```</div><div>extension MyComparable<T : SignedNumber> { ... }</div><div>```</div></div></div></div>
</blockquote></div><br></div></blockquote></div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span><font color="#888888"><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div>Dan Appel<br></div></div></div></div>
</font></span></blockquote></div></div></div></blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div>Dan Appel<br></div></div></div></div>