<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Even better. +1.<br><br>~Robert Widmann</div><div><br>2016/04/06 14:35、Pyry Jahkola via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> のメッセージ:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><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><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><br class=""></div><div>+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></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>