[swift-evolution] [Draft] Rename Sequence.elementsEqual

Michael Ilseman milseman at apple.com
Mon Oct 16 13:23:35 CDT 2017


Sets being values are not an implementation detail. They have value semantics, and that is part of the guarantee of the type. This is perhaps the most important concept in the standard library.


> On Oct 16, 2017, at 10:27 AM, Kevin Nattinger <swift at nattinger.net> wrote:
> 
>>> 
>>> How is the iteration order of an unordered set or dictionary “publicly observable”? If either is implemented such that it can asynchronously optimize its storage (maybe by rebalancing a tree or merging two non-contiguous array segments or something), its iteration order could change without changing what values it contains. Seems like consecutive calls to “elementsEquals” (or whatever we’re calling it) should return the same answer, if we don’t add, remove, or mutate elements.
>>> 
>> 
>> Sets are values. If you add, remove, or mutate any elements you have a different Set and thus a potentially different ordering of elements.
> 
> An implementation detail. We could make it a class* and AFAICT that wouldn't break any guarantees on Sequence; and the argument applies equally well to any other unordered Sequence, which has no value type or semantics constraint.
> 
> *: obviously we won't, I don't think anyone is advocating that.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171016/0fba5720/attachment.html>


More information about the swift-evolution mailing list