[swift-evolution] [Draft] Rename Sequence.elementsEqual
gparker at apple.com
Mon Oct 16 15:31:14 CDT 2017
> On Oct 16, 2017, at 1:08 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> On Mon, Oct 16, 2017 at 13:15 David Sweeris <davesweeris at mac.com <mailto:davesweeris at mac.com>> wrote:
> On Oct 16, 2017, at 09:21, Michael Ilseman <milseman at apple.com <mailto:milseman at apple.com>> wrote:
>> Sets are values. If you add, remove, or mutate any elements you have a different Set and thus a potentially different ordering of elements.
> From the “value semantics” PoV, yes. But from the “unordered collection of values” PoV, Sets/Dictionaries, being unordered, are semantically free to rearrange the in-memory ordering of their elements without user intervention.
> No, they are not semantically free to do so. The semantics of Collection forbid it, because the iteration order must be multi-pass. As long as the value is unchanged, the iteration order is unchanged. That is a documented, public guarantee of the API.
Even if a Set value has a fixed order, a copy of that value may have a *different* order. How many generic algorithm implementations are going to be confused by that?
Greg Parker gparker at apple.com <mailto:gparker at apple.com> Runtime Wrangler
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution