<div dir="ltr">You can achieve the same result more cleanly with <div><br></div><div><div>func maxY<T:P, U:P>(p1:T, p2: U) -> Int {</div><div> return max(p1.y, p2.y) // No problems here!</div><div>}</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 14, 2015 at 10:03 AM, Paul Cantrell via swift-evolution <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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><span class=""><blockquote type="cite"><div>On Dec 13, 2015, at 11:56 PM, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 13, 2015, at 3:55 PM, Marc Knaup via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div></blockquote></div></div></div></blockquote></span><span class=""><blockquote type="cite" style="font-family:HelveticaNeue"><div><div dir="ltr"><div><blockquote type="cite"><blockquote type="cite">Is there any info yet if and how we will be able to refer to instances of protocols that have associated types?</blockquote></blockquote></div></div></div></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><div style="font-family:HelveticaNeue"><blockquote type="cite"><blockquote type="cite">As far as I know, this isn't a solvable problem.</blockquote></blockquote></div></span></div><span class=""><div><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></div><blockquote type="cite"><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div dir="ltr"><div>What is the difficulty in supporting this?</div></div></div></blockquote><br></div><div>Here's a simple example:</div><div><br></div><div>protocol P {</div><div> typealias A</div><div> var x: A { get set }</div><div>}</div><div><br></div><div>struct Y : P {</div><div> var x: Int</div><div>}</div><div><br></div><div>struct Z : P {</div><div> var x: String</div><div>}</div><div><br></div><div>func f(p1: P, p2: P) {</div><div> p1.x = p2.x // assigning an Int to a String?</div><div>}</div></div></blockquote><br></span></div><div>p1.x = p2.x should be a compiler error, because there’s not enough type information. But that shouldn’t stop a programmer from doing this:</div><div><br></div><div><span class=""><div style="word-wrap:break-word"><div>protocol P {</div><div> typealias A</div><div> var x: A { get set }</div></div></span><div> var y: Int</div><span class=""><div style="word-wrap:break-word"><div>}</div><div><br></div><div>struct Y : P {</div><div> var x: Int</div></div></span><div style="word-wrap:break-word"><div> var y: Int</div></div><span class=""><div><div style="word-wrap:break-word"></div></div><div style="word-wrap:break-word"><div>}</div><div><br></div><div>struct Z : P {</div><div> var x: String</div></div></span><div> var y: Int<br></div><div style="word-wrap:break-word"><div>}</div><div><br></div></div><div style="word-wrap:break-word"><div>func maxY(p1: P, p2: P) -> Int {</div><div> return max(p1.y, p2.y) // No problems here!</div><div>}</div></div><div><div style="word-wrap:break-word"><div><br></div><div>…right?</div><div><br></div><div>Cheers, P</div><div><br></div></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1p9Jer2O6jVE9KWvo-2B9iUaEyN8slp4IizyiLwsfp54Pf29ZeGQ869EfUElXAJH5tAK8E-2BcWCI4TUtgPPpNaQX-2FabK11JK6glNFNFK4KSp-2FSIrBBCG02Kv3IlmfFCpoqNsEx28po3nr67qV5BoVsARirFr4Kl8j3zN5KJ2RKi0EvIQqTBBtA3u7oTQdhFokN4bPCoh5WIsSzR9V5lPR4icuceJOIFEzOymDgAR5CGrao-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div>