<div dir="ltr">Here&#39;s a proposal draft. Comments welcome:<div><br></div><div><a href="https://gist.github.com/jtbandes/7978dc1848f7c37eeaa8e9aba27c7325">https://gist.github.com/jtbandes/7978dc1848f7c37eeaa8e9aba27c7325</a></div><div class="gmail_extra">
<br><div class="gmail_quote">On Fri, Jul 22, 2016 at 2:51 PM, Ben Rimmington <span dir="ltr">&lt;<a href="mailto:me@benrimmington.com" target="_blank">me@benrimmington.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
&gt; On 22 Jul 2016, at 20:43, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com">jtbandes@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; On Fri, Jul 22, 2016 at 8:35 AM, Ben Rimmington &lt;<a href="mailto:me@benrimmington.com">me@benrimmington.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On 22 Jul 2016, at 02:46, Jacob Bandes-Storch wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In the swift-lang Slack channel, a few of us were discussing joined(separator:) and realized that flatten() does almost exactly the same thing.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Is there interest in renaming flatten() to joined()?  Since joined takes a separator that&#39;s any Sequence, we can&#39;t have a default value for the separator parameter, but we can have a variant of joined() with no arguments.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;d like default separators for the joined() methods.<br>
&gt;&gt;<br>
&gt;&gt; &lt;<a href="https://bugs.swift.org/browse/SR-1428" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/SR-1428</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; But renaming flatten() to joined() seems complicated.<br>
&gt;&gt;<br>
&gt;&gt; &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Flatten.swift.gyb" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/Flatten.swift.gyb</a>&gt;<br>
&gt;&gt; &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Join.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/Join.swift</a>&gt;<br>
&gt;<br>
&gt; What makes it seem complicated? At the very least, one could just rename the flatten() function. There might also be an opportunity to combine the two files and delete some code from stdlib.<br>
<br>
</span>There&#39;s only one joined() method (for a sequence of sequences):<br>
<br>
        extension Sequence {<br>
          func joined&lt;Separator: Sequence&gt;(separator: Separator) -&gt; JoinedSequence&lt;Self&gt;<br>
        }<br>
<br>
There are many flatten() methods (`where` clauses omitted for brevity):<br>
<br>
        extension Sequence {<br>
          func flatten() -&gt; FlattenSequence&lt;Self&gt;<br>
        }<br>
<br>
        extension LazySequenceProtocol {<br>
          func flatten() -&gt; LazySequence&lt;FlattenSequence&lt;Self.Elements&gt;&gt;<br>
        }<br>
<br>
        extension LazyCollectionProtocol {<br>
          func flatten() -&gt; LazyCollection&lt;FlattenCollection&lt;Self.Elements&gt;&gt;<br>
        }<br>
<br>
        extension Collection {<br>
          func flatten() -&gt; FlattenCollection&lt;Self&gt;<br>
        }<br>
<br>
        extension BidirectionalCollection {<br>
          func flatten() -&gt; FlattenBidirectionalCollection&lt;Self&gt;<br>
        }<br>
<br>
So it&#39;s not a simple one-to-one rename.<br>
<br>
When there&#39;s no `separator` argument, will FlattenIterator perform better than JoinedIterator?<br>
<span class=""><br>
&gt;&gt; And what would happen to the flatMap() methods? Is flatten() a term of art?<br>
&gt;&gt;<br>
&gt;&gt; &lt;<a href="https://github.com/apple/swift/blob/master/stdlib/public/core/FlatMap.swift" rel="noreferrer" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/FlatMap.swift</a>&gt;<br>
&gt;<br>
&gt; I&#39;d say flatMap is more a &quot;term of art&quot; than flatten. &quot;flatten&quot; just describes literally what is being done. Frankly I&#39;m surprised it was never named flattened(). Anyway, flatMap should stay.<br>
<br>
</span>## Future directions<br>
<br>
Will the flatMap(_:) methods also have flatMap(separator:_:) variants?<br></blockquote><div><br></div><div>That&#39;s an interesting idea. It seems to be purely additive, however, so I imagine it wouldn&#39;t happen until after Swift 3.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-- Ben<br>
<br>
</font></span></blockquote></div><br></div></div>