<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 6, 2016 at 11:36 AM Pyry Jahkola via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><blockquote type="cite">On 06 Apr 2016, at 21:30, Developer via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></blockquote></div><div style="word-wrap:break-word"><div><blockquote type="cite"><br><div><div>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><br></div></div></div><div style="word-wrap:break-word"><div><div>+1 already!</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div>Or, if you're feeling ambitious, even<br><br>func anyCommonElements <T, U><br>where T : SequenceType, U : SequenceType,<br>T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element<br>(lhs: T, _ rhs: U) -> Bool<br></div></div></blockquote></div></div><div style="word-wrap:break-word"><div></div><br><div>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><br></div><div><span style="font-weight:bold;font-family:Menlo-Regular;font-size:11px">func anyCommonElements<T, U></span><span style="font-family:Menlo-Regular;font-size:11px"><b>(lhs: T, _ rhs: U) -> Bool</b></span></div></div><div style="word-wrap:break-word"><div><span style="font-family:Menlo-Regular;font-size:11px"><b><font color="#7b219f"> where T : SequenceType,</font></b></span></div><div><b><font color="#7b219f"><span style="font-family:Menlo-Regular;font-size:11px"> U : SequenceType,</span><br style="font-family:Menlo-Regular;font-size:11px"><span style="font-family:Menlo-Regular;font-size:11px"> T.Generator.Element: Equatable,</span></font></b></div><div><b><font color="#7b219f"><span style="font-family:Menlo-Regular;font-size:11px"> T.Generator.Element == U.Generator.Element</span><br style="font-family:Menlo-Regular;font-size:11px"></font></b></div></div><div style="word-wrap:break-word"><div><span style="font-family:Menlo-Regular;font-size:11px">{</span></div><div><span style="font-family:Menlo-Regular;font-size:11px"> ...</span></div><div><span style="font-family:Menlo-Regular;font-size:11px">}</span></div><br>
That would make the definition look closer to what the call site looks like.<div><br></div><div>The same would work for generic types too:</div><div><br></div><div><font face="Menlo" style="font-size:11px">public struct Dictionary<Key, Value></font></div><div><font face="Menlo" style="font-size:11px"> where Key : Hashable</font></div><div><font face="Menlo" style="font-size:11px">{</font></div><div><font face="Menlo" style="font-size:11px"> ...</font></div><div><font face="Menlo" style="font-size:11px">}</font></div></div></blockquote><div><br></div><div><span style="font-size:13px">I very much like this suggestion.</span> </div></div></div>