<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<Element> { … }</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>func anyStringFoo(lhs:Foo<String>) { … }</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<T:SequenceType, U:SequenceType>(lhs:T, _ rhs:U) -> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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 <T, U><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) -> 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<T, U></span><span style="font-family: Menlo-Regular; font-size: 11px;" class=""><b class="">(lhs: T, _ rhs: U) -> Bool</b></span></div><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class=""><b class=""><font color="#7b219f" class=""> 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=""> U : SequenceType,</span><br style="font-family: Menlo-Regular; font-size: 11px;" class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class=""> 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=""> 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=""> ...</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 too:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">public struct Dictionary<Key, Value></font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> 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=""> ...</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>