<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>In your earlier emails you wrote</div><div><br></div><div>"<span style="background-color: rgba(255, 255, 255, 0);">To make it concrete, say you write a function that just wraps map:</span></div><pre><font face="UICTFontTextStyleTallBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);">
func firstNames(ofPeople people: Sequence&lt;Person&gt;) -&gt; Sequence&lt;Person&gt; {</span></font><span style="white-space: normal; background-color: rgba(255, 255, 255, 0); font-family: UICTFontTextStyleTallBody;">&nbsp;return people.map { $0.firstName }
}&nbsp;</span></pre><pre><font face="UICTFontTextStyleTallBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);">&nbsp;I want that function to work on both ordered and unordered Sequences, and if you start with an ordered Sequence you should end up with an ordered Sequence. How do I make that work?"</span></font></pre><div>Your example _won't work even today_ as `map` _returns an Array_ and _not_ a Sequence, like I have written several times now including in the very email you have been answering.</div><div>So you would just write the method with the most general argument type which is required by the method:</div><div><br></div><div>func firstNames(ofPeople people: Iterable&lt;Person&gt;) -&gt; [String] {</div><div>&nbsp; &nbsp;&nbsp;<span style="background-color: rgba(255, 255, 255, 0);">return people.map { $0.firstName }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">The return type would still be Array _just like today_.</span></div><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">-Thorsten</span></div><div><br></div><div><br>Am 19.10.2017 um 01:30 schrieb Adam Kemp &lt;<a href="mailto:adam_kemp@apple.com">adam_kemp@apple.com</a>&gt;:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8">Please re-read my earlier emails with concrete examples of problems this split would cause:<div class=""><br class=""></div><div class=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171016/040501.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171016/040501.html</a></div><div class=""><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171016/040540.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171016/040540.html</a></div><div class=""><br class=""></div><div class="">You’re not thinking far enough ahead about the consequences of this change. It’s not just about map, and it’s not even just about the functions that already exist today. It’s about all of the future functions that you and I and every other Swift developer is going to write dealing with Sequences. Think about the impact on those functions.</div><div class=""><br class=""></div><div class="">I’ve written many functions in C# that fit this pattern, and if C# had split IEnumerable in the same way you propose then my job would have been much harder.</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 18, 2017, at 4:14 PM, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 24px; 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Am 18.10.2017 um 22:04 schrieb Adam Kemp &lt;<a href="mailto:adam_kemp@apple.com" class="">adam_kemp@apple.com</a>&gt;:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Oct 18, 2017, at 12:25 PM, Thorsten Seitz via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Therefore having `elementsEqual` as API for unordered collections is a source of bugs …<br class=""></blockquote><br class="">You keep saying that, and yet after repeated requests to provide evidence you still have not backed up this claim. How many bugs are caused by this? Hypotheticals are not evidence. Show us how much of a problem this is in the real world. Why do you think this is so important to fix? What impact is it going to have? If it weren’t for this thread would you even know the problem existed?<br class=""><br class=""><blockquote type="cite" class="">Adam expressed the concern that this required `map` to implemented separately for the split APIs: `Iterable.map` would have to return an `Iterable` whereas `Sequence.map` would have to return a `Sequence`.<span class="Apple-converted-space">&nbsp;</span><br class="">This is an independent issue IMO, because currently we have a similar situation: `Collection.map` does not return a `Collection` either. It returns an Array. This is a compromise partly due to missing language features which can simply remain when `Sequence` is split.<br class=""></blockquote><br class="">That description does not come close to showing the magnitude of the problem with this approach. The reason you think it’s not a significant problem is that you’re only looking at a single function (map). This problem isn’t specific to just one function, though. The problem is that every single function that takes in one Sequence and returns another Sequence would have to handle this distinction, including functions that you and I will want to write and reuse. That means either:<br class=""><br class="">1. Implement the function twice to handle either ordered or unordered.<br class="">2. Only handle one type.<br class="">3. Implement a complex new language feature that makes #1 slightly easier, but still harder than it is today.<br class=""><br class="">That’s not an improvement. It’s a huge regression in usability. To make that kind of change should require a much stronger argument than “hypothetically this could lead to bugs”.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Is it really such a huge regression? You already have to decide whether to use `Sequence` or `Collection` or `BiDirectionalCollection` etc. Or maybe just `Array` or `Set` or `Dictionary`.</span><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Most such functions (like map, flatMap, filter) currently return `Array`. These will not be better or worse than before.</span><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">For example, `dictionary.map(f)` will result in an `Array` instead of a `Dictionary` where just the values have been replaced. You see, the problem already exists.</span><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">For functions that do not change the element type we can use existing language features like associated types as it is already done with `SubSequence`.</span><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 24px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">-Thorsten</span></div></blockquote></div><br class=""></div></div></blockquote></body></html>