Skip to content
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

[stdlib] Add note to swap() docstring about non-aliasing requirement #490

Merged
merged 1 commit into from
Dec 14, 2015

Conversation

lilyball
Copy link
Contributor

No description provided.

@gribozavr
Copy link
Contributor

This is not specific to swap, this is a general requirement for inout. It might be worth calling out here, true, but we need to be conscious that we won't catch all places with notes like this.

@lilyball
Copy link
Contributor Author

True, this just seemed like the spot with the highest risk of aliasing. For example, when shuffling a list, it's easy to forget to check that you aren't trying to swap a location with itself, so calling it out specifically in the documentation is a good reminder.

@NachoSoto
Copy link
Contributor

In fact this bit me in the Swift 1.2 -> 2 transition IIRC. A naively-implemented shuffle method started crashing because of this change in behavior, so I agree it would be worth calling out.

gribozavr added a commit that referenced this pull request Dec 14, 2015
[stdlib] Add note to swap() docstring about non-aliasing requirement
@gribozavr gribozavr merged commit a014eab into swiftlang:master Dec 14, 2015
@lilyball lilyball deleted the swap-docstring-requires branch December 15, 2015 03:27
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.

3 participants