Skip to content

[WIP][DNM] add is known identical method to equatable protocol #2876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vanvoorden
Copy link

@vanvoorden vanvoorden commented Jun 5, 2025

Many types in Standard Library are “copy-on-write” data structures. These types present as value types, but can leverage a reference to some shared state to optimize for performance. When we copy this value we copy a reference to shared storage. If we perform a mutation on a copy we can preserve value semantics by copying the storage reference to a unique value before we write our mutation: we “copy” on “write”.

This means that many types in Standard Library already have some private reference that can be checked in constant-time to determine if two values are identical. Because these types copy before writing, two values that are identical by their shared storage must be equal by value.

@vanvoorden
Copy link
Author

@lorentey here is the “companion” to #2875. Please let me know if you have any thoughts about this one. My plan was to share this on the forums 2025-06-16 after WWDC. Thanks!

@vanvoorden vanvoorden changed the title [WIP][DNM] add is known identical method [WIP][DNM] add is known identical method to equatable protocol Jun 5, 2025
@vanvoorden vanvoorden marked this pull request as draft June 6, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant