<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">(I saw this after I sent my reply to Benjamin G). We can also deprecate it or warn when the type is concretely known to be Set. Not a total solution, but it’s nice to catch some bugs.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 17, 2017, at 1:21 PM, Manolo van Ee &lt;<a href="mailto:manolo.vanee@gmail.com" class="">manolo.vanee@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><div class="gmail_quote"><div class="">On Tue, 17 Oct 2017 at 21:00, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 17, 2017, at 11:47 AM, Michael Ilseman via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-1627342453204751593Apple-interchange-newline"><div class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">`==` conveys substitutability of the two Sequences. This does not necessarily entail anything about their elements, how those elements are ordered, etc., it just means two Sequences are substitutable. `elementsEqual` means that the two Sequences produce substitutable elements. These are different concepts and both are independently useful.</span></div></blockquote></div><br class=""></div><div style="word-wrap:break-word" class=""><div class="">I agree that ‘==‘ conveys substitutability.&nbsp; Here is the issue:</div><div class=""><br class=""></div><div class=""><span class="m_-1627342453204751593Apple-tab-span" style="white-space:pre-wrap">        </span>let a = Set([1,2,3,4,5])</div><div class=""><span class="m_-1627342453204751593Apple-tab-span" style="white-space:pre-wrap">        </span>let b = Set([5,4,3,2,1])</div><div class=""><br class=""></div><div class=""><span class="m_-1627342453204751593Apple-tab-span" style="white-space:pre-wrap">        </span>a == b //True, they are substitutable</div><div class=""><br class=""></div><div class=""><span class="m_-1627342453204751593Apple-tab-span" style="white-space:pre-wrap">        </span>[1,2,3,4,5].elementsEqual(a) //True</div><div class=""><span class="m_-1627342453204751593Apple-tab-span" style="white-space:pre-wrap">        </span>[1,2,3,4,5].elementsEqual(b) //False… I guess they weren’t actually substitutable after all</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div></div>_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div></div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">I read along with most of the thread and like to add one thing. Maybe it’s not the right way to look at things, but I see protocol extensions as being part of any type that conforms to the protocol. As it is now, code completion on a Set will present me with the elementsEqual function, which in my view is misleading, since it cannot be used in any useful way with a Set.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">By renaming elementsEqual we might be able to make it less misleading, but it will always be a useless function that is part of the Set namespace (or Dictionary for that matter).</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">I don’t know what the best solution would be, but to me it feels like distinguishing between Iterable and Sequence, or Ordered and Unordered makes sense, and it might be good to at least investigate what the impact would be.</div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Regards,</div><div dir="auto" class="">/Manolo</div><div dir="auto" class=""><br class=""></div><div dir="auto" class=""><br class=""></div><div dir="auto" class=""><br class=""></div><div dir="auto" class=""><br class=""></div>
</div></blockquote></div><br class=""></body></html>