<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>The fact is, no matter how much it surprises and bothers you, there is clear evidence from the reactions in this thread that the proposed name is not as clear as you think it is. It doesn’t matter why. This thread could be more productive if you would consider the various other proposed names with an open mind instead of just expressing shock that people don’t interpret the proposed name the way you would like them to. There’s nothing you can do about that. It’s just the way it is. Let’s see what we can come up with that more people intuitively understand.&nbsp;</div><div><br>On Oct 14, 2017, at 9:49 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Sat, Oct 14, 2017 at 11:25 PM, Jonathan Hull <span dir="ltr">&lt;<a href="mailto:jhull@gbis.com" target="_blank">jhull@gbis.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Because the mathematical term you talk about has conditions which must be met to be used/valid.&nbsp; Namely:<div><br></div><div>1) The “Alphabet” of elements must be totally ordered</div><div>2) The lexicographical comparison must be applied to ordered sequences of elements from that alphabet</div><div><br></div><div>Neither of those conditions are met for an unordered generic collection (e.g. a set of equatable, but not comparable elements).</div></div></blockquote><div><br></div><div><div>This is diametrically the opposite claim that Michael just made. 
Here, you argue that the confusion stems from the extension of the term 
to sequences with elements that are equatable but not comparable because there *isn't* a total ordering for the elements. Michael just 
said that the term is confusing particularly with Ints *because* they 
have an obvious total ordering (i.e., they are comparable). And in fact, the apparently common 
misconception is that the function would instead sort the elements of each sequence by 
that ordering, which is obviously inapplicable for equatable but not 
comparable elements, and such a misconception is therefore impossible in that scenario.<br></div><div><br></div><div>_The very first result on Google_ defines lexicographical comparison unambiguously for C++:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><p>Lexicographical comparison is a operation with the following properties:
</p>
<ul><li> Two ranges are compared element by element.
</li><li> The first mismatching element defines which range is lexicographically <i>less</i> or <i>greater</i> than the other.
</li><li> If one range is a prefix of another, the shorter range is lexicographically <i>less</i> than the other.
</li><li> If two ranges have equivalent elements and are of the same length, then the ranges are lexicographically <i>equal</i>.
</li><li> An empty range is lexicographically <i>less</i> than any non-empty range.
</li><li> Two empty ranges are lexicographically <i>equal</i>.&nbsp;</li></ul></div></blockquote><div>The purpose behind choosing "lexicographicallyEquals" was that it is a term that has an established meaning, easily googled, that describes the algorithm exactly and unambiguously in two words. If you have seen this term in use, you will know what the Swift method does. If you have not seen this term, then even in the absence of Swift documentation, a single search will lead you to the correct answer. I am simply in disbelief that apparently many people will see a term with which they are unfamiliar, assume it means something it does not, and use the function without consulting the documentation or looking up the term.<br></div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>The underlying issue here is that the “ordering” of the sequence coming out of a set/dictionary is undefined and may rely on internal implementation details.&nbsp; Building anything on top of that is problematic because the foundation is undefined.&nbsp; Lexicographical’s connotation of applying a total order only compounds that original issue, especially if the elements are strings or some other sequential data type.</div></div></blockquote><div><br></div><div>Right, and the purpose of this proposal is to give it such a name that it is obvious that this function is probably not what you want in comparing two concrete sets (much as it is obvious on first glance that `first` is probably not useful when working with concrete sets), without going down the road of attempting to rip out the established protocol hierarchy.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><div class="gmail-h5"><div><div><blockquote type="cite"><div>On Oct 14, 2017, at 8:45 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail-m_-6548967802064675942Apple-interchange-newline"><div><div dir="ltr">On Sat, Oct 14, 2017 at 8:11 PM, Michael Ilseman <span dir="ltr">&lt;<a href="mailto:milseman@apple.com" target="_blank">milseman@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>I think that “match” is a word to avoid for this, as this doesn’t have anything to do with pattern matching, fuzzy matching, etc., while &nbsp;“equals” is precisely the concept we’re using.</div><div><br></div><div>What about the name “sequentiallyEquals”? Highlight the fact that we’re talking about sequential ordering, i.e. whatever order the sequence provides, as opposed to first doing some lexicographical ordering of elements themselves.</div><div><br></div><div>var a: Set&lt;Int&gt; = &nbsp;[3, 1, 2]</div><div>a.sequentiallyEquals([1,2,3]) // result depends on application of equality in a (potentially-arbitrary) sequential ordering</div><div><br></div><div>Whereas I could see the following being more confusing:</div><div><br></div><div><div>var a: Set&lt;Int&gt; = &nbsp;[3, 1, 2]</div><div>a.lexicographicallyEquals([1,2<wbr>,3]) // result depends on application of equality, but what meaning does “lexicographically” convey?</div></div><div><br></div><div>It’s not immediately clear to someone new to the API that “lexicographically” speaks to the nature of the sequence’s (potentially-arbitrary) order, irrespective of element. It could give the false impression that it speaks to some nature of the elements themselves, in this case Ints, which have an obvious lexicographical ordering. I don’t know how frequent that misconception would be in practice, but it does cause me to do a double-take in this contrived example.</div><div><div class="gmail-m_-6548967802064675942h5"><div><br></div></div></div></div></blockquote><div><br></div><div>I'm entirely puzzled that apparently large numbers of people believe lexicographical comparison, a term with a very specific mathematical definition and no colloquial use, to mean what it does not. I'd like to avoid inventing Swift-specific new terms for this particular concept which is not at all unique to Swift. The other plausible terms I can see with some other use might be "elementwise equals" or "entrywise equals" or "coordinatewise equals."<br></div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><div class="gmail-m_-6548967802064675942h5"><div></div><div><br></div><div><blockquote type="cite"><div>On Oct 14, 2017, at 1:04 PM, Benjamin G via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail-m_-6548967802064675942m_669914145015844915Apple-interchange-newline"><div><div dir="ltr">To answer more precisely this request (which remains valid no matter the protocol hierarchy). I propose<div><br></div><div>"matchesSequence" ( or simply "matches" or "match", whatever is more coherent with the naming guidelines).</div><div><br></div><div>So</div><div>var a: [Int] = [1,2,3]</div><div>a.matchesSequence([1,2,3]) returns true.</div><div><br></div><div>I first thought that the verb "matching" was too heavily associated to regular expressions, but i think that it's the correct equivalent for something as general as a sequence.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 13, 2017 at 1:24 AM, Xiaodi Wu via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><h1>Rename <code>Sequence.elementsEqual</code></h1>
<ul><li>Proposal: <a href="https://gist.github.com/xwu/NNNN-rename-elements-equal.md" target="_blank">SE-NNNN</a></li><li>Authors: <a href="https://github.com/xwu" target="_blank">Xiaodi Wu</a></li><li>Review Manager: TBD</li><li>Status: <b>Awaiting review</b></li></ul><h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#introduction" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-introduction" target="_blank"></a>Introduction</h2><p>The current behavior of <code>Sequence.elementsEqual</code> is 
potentially confusing to users given its name. Having surveyed the 
alternative solutions to this problem, it is proposed that the method be
 renamed to <code>Sequence.lexicographicallyEqua<wbr>ls</code>.</p>

<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#motivation" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-motivation" target="_blank"></a>Motivation</h2><p><a href="https://twitter.com/olebegemann/status/916291785185529857" target="_blank">As outlined by Ole Begemann</a>, use of <code>Sequence.elementsEqual(_:)</code> can lead to surprising results if the sequences compared are unordered:</p>
<div class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-highlight gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-highlight-source-swift"><pre><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">var</span> set1<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Set</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">&lt;</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Int</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">&gt;</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">=</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Set</span>(<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">1</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">...</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">5</span>)
<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">var</span> set2<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Set</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">&lt;</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Int</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">&gt;</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">=</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Set</span>((<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">1</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">...</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">5</span>).<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">reversed</span>())

set1 <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">==</span> set2 <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c">//</span> true</span>
<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c"></span>set1.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">elementsEqual</span>(set2) <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c">//</span> false</span></pre></div><p>This result does reflect the <b>intended and documented</b> behavior of the <code>elementsEqual(_:)</code> method, which performs a <b>lexicographical</b> elementwise comparison. That is, the method first compares <code>set1.first</code> to <code>set2.first</code>, then (if the two elements compare equal) compares the next element stored internally in <code>set1</code> to the next element stored internally in <code>set2</code>, and so on.</p><p>In almost all circumstances where a set is compared to another set, 
or a dictionary is compared to another dictionary, users should use <code>==</code> instead of <code>elementsEqual(_:)</code>.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#proposed-solution" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-proposed-solution" target="_blank"></a>Proposed solution</h2><p>The proposed solution is the result of an iterative process of reasoning, presented here:</p><p>The first and most obvious solution is to remove the <code>elementsEqual(_:)</code> method altogether in favor of <code>==</code>. This prevents its misuse. However, because <code>elementsEqual(_:)</code> is a generic method on <code>Sequence</code>, we can use it to compare an instance of <code>UnsafeBufferPointer&lt;Int&gt;</code> to an instance of <code>[Int]</code>. This is a useful and non-redundant feature which would be eliminated if the method is removed altogether.</p><p><a href="https://github.com/apple/swift/pull/12318" target="_blank">A second solution</a> is to create overloads that forbid the use of the <code>elementsEqual(_:)</code>
 method specifically in non-generic code. This would prevent misuse in 
non-generic code; however, it would also forbid legitimate mixed-type 
comparisons in non-generic code while failing to prevent misuse in 
generic code. The solution also creates a difference in the behavior of 
generic and non-generic code calling the same method, which is 
potentially confusing, without solving the problem completely.</p><p>A third solution is to dramatically overhaul the protocol hierarchy 
for Swift sequences and collections so that unordered collections no 
longer have members such as <code>first</code> and <code>elementsEqual(_:)</code>.
 However, this would be a colossal and source-breaking undertaking, and 
it is unlikely to be satisfactory in addressing all the axes of 
differences among sequence and collection types:</p>
<ul><li>Finite versus infinite</li><li>Single-pass versus multi-pass</li><li>Ordered versus unordered</li><li>Lazy versus eager</li><li>Forward/bidirectional/random-a<wbr>ccess</li></ul><p>A fourth solution is proposed here. It is predicated on the following observation:</p><p><i>Another method similar to <code>elementsEqual(_:)</code> already exists on <code>Sequence</code> named <code>lexicographicallyPrecedes(_:)</code>. Like <code>first</code>, <code>elementsEqual(_:)</code>, <code>drop(while:)</code>,
 and others, it relies on the internal order of elements in a manner 
that is not completely suitable for an unordered collection. However, 
like <code>first</code> and unlike <code>elementsEqual(_:)</code>, this fact is called out in the name of the method; unsurprisingly, like <code>first</code> and unlike <code>elementsEqual(_:)</code>, there is no evidence that <code>lexicographicallyPrecedes(_:)</code> has been a pitfall for users.</i></p><p>This observation suggests that a major reason for confusion over <code>elementsEqual(_:)</code> stems from its name. So, <b>it is proposed that <code>elementsEqual(_:)</code> should be renamed to <code>lexicographicallyEquals(_:)</code></b>.
 The function will remain somewhat of a poor fit for unordered 
collections, but no more so than many other methods that cannot 
trivially be removed from the API of unordered collections (as discussed
 above). The key is that, with such a renaming, the behavior of this 
method will no longer be confusing.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#detailed-design" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-detailed-design" target="_blank"></a>Detailed design</h2>
<div class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-highlight gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-highlight-source-swift"><pre><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">extension</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-en"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Sequence</span></span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">where</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Element</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-e"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Equatable</span></span> {
  <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">@available</span>(<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">*</span>, <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">deprecated</span>, <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">message</span>: <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-s"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-pds">"</span>Use '==' if possible to compare two sequences of the same type, or use 'lexicographicallyEquals' to compare two ordered sequences.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-pds">"</span></span>)
  <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">public</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">func</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-en">elementsEqual</span>&lt;<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Other</span> : <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-e"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Sequence</span></span>&gt;(
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-en">_</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-smi">other</span>: Other
  ) <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">-&gt;</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Bool</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">where</span> Other.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Element</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">==</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Element</span> {
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">return</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">lexicographicallyEquals</span>(other)
  }
  
  <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">public</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">func</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-en">lexicographicallyEquals</span>&lt;<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Other</span> : <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-e"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Sequence</span></span>&gt;(
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-en">_</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-smi">other</span>: Other
  ) <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">-&gt;</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Bool</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">where</span> Other.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Element</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">==</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">Element</span> {
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c"><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c">//</span> The body of this method is unchanged.</span>
<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c"></span>    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">var</span> iter1 <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">=</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">self</span>.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">makeIterator</span>()
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">var</span> iter2 <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">=</span> other.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">makeIterator</span>()
    <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">while</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">true</span> {
      <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">switch</span> (iter1.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">next</span>(), iter2.<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">next</span>()) {
      <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">case</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">let</span> (e1<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">?</span>, e2<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">?</span>)<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span>
        <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">if</span> e1 <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">!=</span> e2 { <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">return</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">false</span> }
      <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">case</span> (<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">_</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">?</span>, <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">nil</span>), (<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">nil</span>, <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">_</span><span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">?</span>)<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span>
        <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">return</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">false</span>
      <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">case</span> (<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">nil</span>, <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">nil</span>)<span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">:</span>
        <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-k">return</span> <span class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-pl-c1">true</span>
      }
    }
  }
}</pre></div><p>A parallel change will be made with respect to <code>elementsEqual(_:by:)</code>; that is, it will be deprecated in favor of <code>lexicographicallyEquals(_:by:)</code><wbr>.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#source-compatibility" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-source-compatibility" target="_blank"></a>Source compatibility</h2><p>Existing code that uses <code>elementsEqual</code> will gain a deprecation warning.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#effect-on-abi-stability" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-effect-on-abi-stability" target="_blank"></a>Effect on ABI stability</h2><p>None.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#effect-on-api-resilience" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-effect-on-api-resilience" target="_blank"></a>Effect on API resilience</h2><p>This proposal adds new methods to the public API of <code>Sequence</code> and conforming types.</p>
<h2><a href="https://gist.github.com/xwu/1f0ef4e18a7f321f22ca65a2f56772f6#alternatives-considered" class="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-anchor" id="gmail-m_-6548967802064675942m_669914145015844915m_2762727181953316915gmail-user-content-alternatives-considered" target="_blank"></a>Alternatives considered</h2><p>It is to be noted that <code>lexicographicallyPrecedes(_:by<wbr>:)</code> and <code>elementsEqual(_:by:)</code>
 are essentially the same method, since both perform a lexicographical 
comparison using a custom predicate. However, there is not a good 
unifying name. (<code>lexicographicallyCompares(to:<wbr>by:)</code> reads 
poorly.) Moreover, the predicate supplied is intended to have very 
different semantics, and maintaining two distinct methods may be a 
superior fit with the typical user's mental model of the intended 
behavior and may also be clearer to readers of the code. Therefore, this
 proposal does not seek to unify the two methods; instead, <code>elementsEqual(_:by:)</code> will be renamed <code>lexicographicallyEquals(_:by:)</code> as detailed above.</p></div>
<br>______________________________<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/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
______________________________<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" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div>
______________________________<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" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></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>