Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Inconsistent editorial style for removing elements in Set.prototype.difference #99

Closed
syg opened this issue Jun 21, 2023 · 3 comments · Fixed by #100
Closed

Inconsistent editorial style for removing elements in Set.prototype.difference #99

syg opened this issue Jun 21, 2023 · 3 comments · Fixed by #100

Comments

@syg
Copy link

syg commented Jun 21, 2023

In difference, the "receiver is <= in size than argument" path removes elements from the result set by setting the removed element in [[SetData]] to ~empty~, while the "receiver is > in size than argument" path removes elements with the "remove" verb, which AFAICT we don't really do. Was this a conscious choice?

@bakkot
Copy link
Collaborator

bakkot commented Jun 21, 2023

Was this a conscious choice?

Yes, but I see why it's confusing. The idea is that the result sets are not observable until the methods return, so there's no possible outstanding iterators, which are what normally necessitates the ~empty~ tombstones. But in difference specifically, we're iterating over the set by index, and the index would be invalidated if we removed an element without having a tombstone.

I can change it to be more consistent. Do you have a preference between the two styles?

@syg
Copy link
Author

syg commented Jun 21, 2023

Ah I see, makes sense. I think the observability part is a bit subtle. If you have no objections against making consistent, I prefer the use of ~empty~ tombstones everywhere. I am also fine with it remaining as it is (which I am fine with, given the explanation), though that still strikes me as optimizing a spec implementation that is already asymptotically bad, so why bother.

@bakkot
Copy link
Collaborator

bakkot commented Jun 21, 2023

See #100

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants