<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 28, 2016, at 12:40 PM, Thorsten Seitz <<a href="mailto:tseitz42@icloud.com">tseitz42@icloud.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">Am 27.05.2016 um 20:47 schrieb Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 27, 2016, at 12:05 PM, Charles Srstka 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 May 27, 2016, at 9:31 AM, plx 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=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">For the Sequence/Collection it’s a lot of work for IMHO a rather minor convenience, but for more-complex type associated-type relationships it could start to pay its own way.</span></div></blockquote></div><br class=""><div class="">Is it really that minor, though? For something so commonly encountered as methods that take sequences/collections, this:</div><div class=""><br class=""></div><div class="">func doSomething(foos: [Foo], bars: [Bar], bazzes: [Baz])</div><div class=""><br class=""></div><div class="">is not only a whole lot easier to type, but is worlds clearer to read than:</div><div class=""><br class=""></div><div class="">func doSomething<S: SequenceType, T: SequenceType, U: SequenceType where S.Generator.Element == Foo, T.Generator.Element == Bar, U.Generator.Element == Baz>(foos: S, bars: T, bazzes: U)</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Not only is the latter line intimidating to look at as is, but it separates the contained type from the parameters themselves. Given how unwieldy this second form is, it seems almost certain that the former line will be used more frequently in the real world.</div></div></div></blockquote><div class=""><br class=""></div><div class="">When generalized existentials are introduced (Austin Zheng has a proposal for this) you will be able to do this (assuming we switch to the `&` syntax:</div><div class=""><br class=""></div><div class="">typealias SequenceOf<T> = Sequence where .Element == T</div><div class=""><br class=""></div><div class="">func doSomething(foos: SequenceOf<Foo>, bars: SequenceOf<Bar>, bazzes: SequenceOf<Baz>)</div></div></div></div></blockquote><div><br class=""></div>That’s a really nice solution, which gets even nicer with plx suggestion of putting the typealias within the protocol like this: </div><div><div class=""><br class=""></div><div class="">protocol Sequence {</div><div class=""> typealias of<E> = S: Self where .Element == E</div><div class="">}</div></div></div></blockquote><div><br></div>That is very nice!<div><br><blockquote type="cite"><div><div><div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""></div><div class="">It’s still slightly more verbose than the array shorthand, but it’s a far cry from what you have to do with generics today.</div><div class=""><br class=""></div><div class="">If you wanted it to be generic you could write it as:</div><div class=""><br class=""></div><div class="">func doSomething<S: SequenceOf<Foo>, T: SequenceOf<Bar>, SequenceOf<Baz>(foos: S, bars: T, bazzes: U)</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></blockquote></div></body></html>