<div dir="ltr">I&#39;m sorry but you&#39;re still arguing about the coherence of the protocol (which you did convinced me about). <div>What some people still argue about is the impact on the coherence of the Set. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 14, 2017 at 9:54 PM, Xiaodi Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br><div class="gmail_quote"><span class=""><div dir="auto">On Sat, Oct 14, 2017 at 14:36 Benjamin G &lt;<a href="mailto:benjamin.garrigues@gmail.com" target="_blank">benjamin.garrigues@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I think what you&#39;re saying and what Kevin is saying are in way not contradictory : <div><br><div>You&#39;re saying the &quot;SpongeBob&quot; protocol functions make sense and are coherent, Kevin is saying the consequence is that it creates weird functions for Sets, and i think you&#39;re both right.<br></div></div><div><br></div><div>an &quot;UnorderedSequence&quot; may very well have a &quot;first&quot; element. The problem is that when you apply it to sets, you&#39;re not calling:</div><div><br></div><div>mySet.<wbr>generatedRandomOrderSequence()<wbr>.first()</div><div><br></div><div>but</div><div><br></div><div>mySet.first()</div><div><br></div><div>That&#39;s where the issue stands, and that&#39;s IMHO, a symptom that the protocol hierarchy is a bit misleading.</div><div>What you would like for sets isn&#39;t &quot;first()&quot;, but &quot;any()&quot;.</div><div></div></div></blockquote><div dir="auto"><br></div></span><div dir="auto">&#39;first&#39; is just a shorthand for &#39;let first; for element in sequence { first = element; break }&#39;. Any type that offers iterated access in a for...in loop must, by construction, have a definable &#39;first&#39;.</div><div dir="auto"><br></div><div dir="auto">Swift Sequences are deliberately allowed to be single-pass, infinite, or unordered. A multi-pass, finite Sequence is a Collection. It&#39;s not an oversight that &#39;first&#39; is defined on Sequence and not Collection. It&#39;s not &#39;weird&#39; to ask what the first element you get on iteration must be; by definition, iteration gives you elements sequentially and something must be first.</div><div><div class="h5"><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br></div><div class="gmail_extra"><div class="gmail_quote"></div></div></div><div><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 14, 2017 at 10:26 AM, Xiaodi Wu via swift-evolution <span>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><span>On Sat, Oct 14, 2017 at 2:28 AM, Kevin Nattinger <span>&lt;<a href="mailto:swift@nattinger.net" target="_blank">swift@nattinger.net</a>&gt;</span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-"><blockquote type="cite"><div>On Oct 13, 2017, at 8:28 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-interchange-newline"><div><br class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-interchange-newline"><br style="font-family:Helvetica;font-size:12px;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"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;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">On Fri, Oct 13, 2017 at 12:03 PM, Kevin Nattinger<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span><span>&lt;<a href="mailto:swift@nattinger.net" target="_blank">swift@nattinger.net</a><wbr>&gt;</span><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div dir="auto" style="word-wrap:break-word"><div dir="auto" style="word-wrap:break-word"><div><span><blockquote type="cite"><div>On Oct 13, 2017, at 6:52 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990m_4644553253174523011Apple-interchange-newline"><div><div><div dir="auto">You’re welcome to bikeshed the entire API surface area of sequences and collections, but you won’t be the first to explore this area. A number of us looked into this area in the past few years and did not reach a measurable improved result.</div></div></div></blockquote><div><br></div></span><div>I don’t need or want to bikeshed the entire sequence and collection surface area, I just want to fix one clear and GLARING issue:</div><div><br></div><div><font size="4">A Set is NOT a sequence.</font></div><div><br></div><div>Note that this goes for dictionaries and any other unordered “sequences&quot; as well.</div><div><br></div><div>That was in an early draft of my original email, but I dropped it because I was afraid people would just stop reading and dismiss the idea out-of-hand without considering the problem or arguments. Apparently I should have at least put it at the bottom, so sorry if the root issue was unclear.</div><span><br><blockquote type="cite"><div><div><div dir="auto">Sequences can be ordered or unordered,</div></div></div></blockquote><div><br></div></span><div>You seem to be confusing the English word “sequence” with the (current) Swift protocol “Sequence.&quot; A sequence is, by definition, ordered. Not enforcing that in a protocol does not override the English language, and as this entire thread demonstrates, causes issues further on down the line.</div></div></div></div></div></blockquote><div><br></div><div>We are discussing the Swift protocol `Sequence`. It really doesn&#39;t matter at all what the English word &quot;sequence&quot; means, and any difference between the English word and the Swift term is emphatically *not* the root cause of the issue. Here&#39;s why:</div><div><br></div><div>* A Swift `Sequence` is, to put it simplistically, a thing that can be iterated over in a `for...in` loop. If it would make you happy, for the rest of the discussion, let&#39;s suppose we called the protocol `ForLoopable` instead of `Sequence`.</div></div></div></blockquote><div><br></div></span><div>ForLoopable is so ugly. Since we’re just iterating over the elements, how about, oh, say, `Iterable`? Hey, that looks familiar.</div></div></div></blockquote><div><br></div></span><div>I&#39;m not trying to bikeshed the name of `Sequence`. I&#39;m picking an intentionally unwieldy name for the purposes of discussing the semantics of this particular protocol. The point is that the underlying issue has nothing to do with the name; it can be `Iterable` or it can be `SpongeBob` for all I care.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-"><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;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"><div><br></div><div>* `Set` should conform to `ForLoopable`. (This I state as a premise; if you disagree with the notion that we should be able to iterate over the elements of an instance of `Set` with a `for...in loop`, then it&#39;s clearly a whole other discussion and not a question of what the English word &quot;sequence&quot; means.)</div></div></div></blockquote><div><br></div></span>Obviously, `Set: Iterable`. I don’t think I’ve said anything to suggest you shouldn’t be able to iterate over unordered collections.</div><div><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-"><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;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"><div><br></div><div>* If a type `T` conforms to `ForLoopable` and an instance `t` of that type has at least one element, then *something* has to be the first element in a `for element in t { ... }` loop. Put another way, every instance of a type that conforms to `ForLoopable` must have at least one publicly observable order (although, intriguingly, I&#39;m not sure it has to be a repeatable one). It is possible, therefore, to have a semantic answer to the question of which element is `first` or (if finite) `last`; one can also `drop(while:)`, etc., and perform lexicographical comparisons.</div></div></div></blockquote><div><br></div></span>As a side effect of Swift being a procedural language each iteration happens to occur in some order, yes, but that order is meaningless and reflects nothing about the Set itself.  In fact, I’d say that <b>`first`, `last`, etc. are not even defined on the original Set per se, only on the specific order that a particular iteration resulted in</b>. And that order is not necessarily predictable, nor necessarily stable, as you yourself said.</div><div><br></div><div>Consider an Iterable that gives a different order every time it’s iterated. </div><div>Should calling `.first` or `last` give a different object every time?  That’s absurd.</div><div>Should an object lexicographically compare not equal to itself? Even more absurd. </div></div></blockquote><div><br></div></span><div>What&#39;s your basis for saying that such behavior is absurd? It is explicitly permitted for instances of types conforming to `SpongeBob` to be single-pass and/or infinite. For a single-pass `SpongeBob`, `first` will certainly return a different value every time it is invoked.</div><div><br></div><div>A random number generator fulfills all the semantic requirements of conforming to `SpongeBob`, and in fact <a href="https://github.com/xwu/NumericAnnex/blob/master/Sources/PRNG.swift#L53" target="_blank">I do just that in NumericAnnex</a>. `first` gives a different value every time, and a randomly generated `SpongeBob` would unsurprisingly compare lexicographically not equal to itself.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div></div><div>On the other hand, if I have a collection of objects that I want iterated in a particular order, I can use a container that iterates in a specific, known, well-defined way, and use that to construct the sequence of objects.  That’s clearly an Iterable collection, but the guarantee is stronger than that. Since it iterates objects in a specific sequence, the logical way to express that would be `Sequence: Iterable`. Again, we’ve seen that before.  </div><div><br></div><div>Now, since a Sequence is guaranteed to iterate the same every time, suddenly our `first`, `last`, `drop*`, etc. methods have a meaning inherent to the collection itself, rather than a specific iteration.</div></div></blockquote><div><br></div></span><div>What you call a &quot;Sequence&quot; here would have to be multi-pass, finite, and ordered. That&#39;s actually more semantically constrained than what Swift calls a `Collection` (which requires conforming types to be multi-pass and(?) finite). By contrast, Swift&#39;s `SpongeBob` protocol explicitly permits conforming single-pass, infinite, and/or unordered types. As long as it is possible to iterate over a `SpongeBob`, it is meaningful to ask what element is first obtained upon iteration or to drop the first element obtained upon iteration. And as long as iteration is not required to be repeatable (and it isn&#39;t), it is perfectly acceptable for these algorithms to return a different result every time.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div>`first` is the first object in the Sequence. It doesn’t matter how the sequence came to be in that order; it doesn’t matter whether or not the sequence has already been iterated or how many times. `first` is the first object that is, was, and always will be presented by the Sequence’s Iterator. (Until the collection is mutated, obviously).</div><div><br></div><div style="font-size:13px"><b>To summarize,</b></div><div>A Set has no intrinsic order. You can iterate over it, and a specific iteration of a set has an order, but that order is not tied to the Set itself beyond including all and only the items therein. Therefore, the Set itself has no intrinsic `first`, `last`, lexicographical comparison, etc.; only its iterations do, and they are not themselves Sets.</div><div>A Sequence does have an intrinsic order. The order of iteration reflects the order inherent to the Sequence. Therefore, a Sequence has a `first`, `last`, lexicographical comparison, etc.</div><div><br></div><div>Just in case it’s not obvious, `Set` here is pretty much interchangeable with any other unordered iterable.</div></div></blockquote><div><br></div></span><div>What you want to call a &quot;Sequence&quot; is what Swift calls a `Collection`, with additional restrictions. What you want to be called &quot;Iterable&quot; is what Swift calls `Sequence` (or now, `SpongeBob`). Clearly, shuffling names will not make these protocols support any more functionality, so that can be put aside.</div><div><br></div><div>Now, with that out of the way, why do you think that only `Collection` types should have `first` and `last`? These helper properties and methods are simply convenient ways to spell things that can be done with `for...in`--the whole point of supplying them is to allow people to work with these types in a more functional style.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-"><div><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;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"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div dir="auto" style="word-wrap:break-word"><div dir="auto" style="word-wrap:break-word"><div><div><div class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990h5"><blockquote type="cite"><div><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(233,175,205);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures">public</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">protocol</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">Iterable</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>{</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(52,188,38);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>Iterator</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">Ite<wbr>ratorProtocol</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(130,185,255);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">map</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">&lt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">T</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">)<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">T</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">]</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">// Iterable where .Iterator.Element == T</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(130,185,255);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">filter</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">)<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">Iterato<wbr>r.Element</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">]</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">// Iterable where .Iterator.Element == Self.Iterator.Element</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(52,187,200);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">forEach</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="font-variant-ligatures:no-common-ligatures">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">)</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(52,187,200);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">makeIterator</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">()<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">Itera<wbr>tor</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(52,187,200);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">var</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">underestimatedCount</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">Int</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"><wbr> </span>{<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">get</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>}</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961);min-height:14px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(130,185,255);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">public</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">protocol</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">Sequence</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">Iter<wbr>able</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>{<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">// Maybe OrderedSequence just to make the well-defined-order requirement explicit</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span>SubSequence</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(130,185,255);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">dropFirst</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">)  <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">// Sequence where .Iterator.Element == Self.Iterator.Element</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">dropLast</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures">)   <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(130,185,255)">//    &quot; &quot;</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">drop</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">while</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures">)  <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(130,185,255)">//    &quot; &quot;</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">prefix</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures">)     <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(130,185,255)">//    &quot; &quot;</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(52,188,38);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">prefix</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">while</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">)<span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">Sub<wbr>Sequence</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(130,185,255)">//    &quot; &quot;</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">suffix</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures">)     <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(130,185,255)">//    &quot; &quot;</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(130,185,255);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"> <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">func</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">split</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">(</span><span style="color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">where</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)">...</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)">) <span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">-&gt;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)"><wbr>[</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">SubSequence</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(233,175,205)">]</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(214,214,214)"><span class="m_-2398609295882344636m_6322127107512678476m_5044554908058054643gmail-m_2877875185135332990Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures">// Iterable where .Iterator.Element == (Sequence where .Iterator.Element == Self.Iterator.Element)</span></div><div style="margin:0px;line-height:normal;font-family:&quot;Andale Mono&quot;;color:rgb(214,214,214);background-color:rgba(0,0,0,0.901961)"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote></div></div></div></div></div></div></blockquote></div></div></blockquote></div><div><br></div></span>And just to be explicit, <div>struct Set: Iterable {…}</div><div>struct Dictionary: Iterable {…}</div><div>struct Array: Sequence {…}</div><div>etc.</div><div><br></div><div>Hopefully at some point:</div><div>struct OrderedSet: Sequence {…}<br><div><br></div></div></div></blockquote></span></div><br></div></div>
<br></blockquote></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div></div></div></blockquote></div></div></div></div>
</blockquote></div><br></div>