<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I quite like this variation, so I’m a +1 for that.</div><div class=""><br class=""></div><div class="">However, I think this would be greatly helped if we could define protocol generics more like type generics like so:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protocol Foo&lt;Element&gt; { … }</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func anyStringFoo(lhs:Foo&lt;String&gt;) { … }</font></div><div class=""><br class=""></div><div class="">But yeah, for the more complicated cases, it makes a lot of sense to relocate the where clause away from the main signature. I’d maybe still allow declarations of type though like-so:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func anyCommonElements&lt;T:SequenceType, U:SequenceType&gt;(lhs:T, _ rhs:U) -&gt; Bool</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>where T.Generator.Element:Equatable, T.Generator.Element == U.Generator.Element</font></div><div class=""><br class=""></div><div class="">Perhaps allowing us the choice of doing it this way at least.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 6 Apr 2016, at 19:35, Pyry Jahkola via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class="">On 06 Apr 2016, at 21:30, Developer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class="">If you've ever gotten to the point where you have a sufficiently generic interface to a thing and you need to constrain it, possibly in an extension, maybe for a generic free function or operator, you know what a pain the syntax can be for these kinds of operations. </div></div></blockquote><div class=""><br class=""></div><div class="">+1 already!</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">Or, if you're feeling ambitious, even<br class=""><br class="">func anyCommonElements &lt;T, U&gt;<br class="">where T : SequenceType, U : SequenceType,<br class="">T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element<br class="">(lhs: T, _ rhs: U) -&gt; Bool<br class=""></div></div></blockquote></div><br class=""><div class="">I would actually move them as far as after everything else, and right before the definition body. For the above function that would mean:</div><div class=""><br class=""></div><div class=""><span style="font-weight: bold; font-family: Menlo-Regular; font-size: 11px;" class="">func anyCommonElements&lt;T, U&gt;</span><span style="font-family: Menlo-Regular; font-size: 11px;" class=""><b class="">(lhs: T, _ rhs: U) -&gt; Bool</b></span></div><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class=""><b class=""><font color="#7b219f" class="">&nbsp; &nbsp; where T : SequenceType,</font></b></span></div><div class=""><b class=""><font color="#7b219f" class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; U : SequenceType,</span><br style="font-family: Menlo-Regular; font-size: 11px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; T.Generator.Element: Equatable,</span></font></b></div><div class=""><b class=""><font color="#7b219f" class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; T.Generator.Element == U.Generator.Element</span><br style="font-family: Menlo-Regular; font-size: 11px;" class=""></font></b></div><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">{</span></div><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">&nbsp; &nbsp; ...</span></div><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">}</span></div><br class="">
That would make the definition look closer to what the call site looks like.<div class=""><br class=""></div><div class="">The same would work for generic types &nbsp;too:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">public struct Dictionary&lt;Key, Value&gt;</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">&nbsp; &nbsp; where Key : Hashable</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">{</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">&nbsp; &nbsp;...</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">}</font></div><div class=""><br class=""></div><div class="">— Pyry</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>