Skip to content

Conversation

@xwu
Copy link
Collaborator

@xwu xwu commented Oct 17, 2025

Update documentation for InlineArray to include examples with type sugar, reword to avoid certain jargon that may be unfamiliar to some standard library users, and incorporate additional details mostly drawn from the proposal text.

Update documentation for `InlineArray` to include examples with type sugar, reword to avoid certain jargon that may be unfamiliar to some standard library users, and incorporate additional details mostly drawn from the proposal text.
@xwu xwu requested a review from a team as a code owner October 17, 2025 05:07
@xwu xwu changed the title Revise InlineArray documentation [stdlib] Revise InlineArray documentation Oct 17, 2025
@xwu xwu requested a review from benrimmington October 17, 2025 05:15
Copy link
Contributor

@benrimmington benrimmington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for working on this. I have a few suggestions, but overall you've greatly improved the documentation.


Should it be stated that the [count of Element] shorthand is preferred?

Array:

Shortened forms are preferred

TSPL — Collection Types:

Although the two forms are functionally identical, the shorthand form is preferred


Should the other example code in this file also be updated?

-  ///     InlineArray<4, Int> { 1 << $0 }  //-> [1, 2, 4, 8]
+  ///     [4 of Int] { 1 << $0 }  //-> [1, 2, 4, 8]
-  ///     InlineArray<4, Int>(first: 1) { $0 << 1 }  //-> [1, 2, 4, 8]
+  ///     [4 of Int](first: 1) { $0 << 1 }  //-> [1, 2, 4, 8]

@xwu
Copy link
Collaborator Author

xwu commented Oct 17, 2025

Some of the doc comments on specific APIs could do with some follow-on revision. I've updated the two code examples you pointed out both to incorporate the shorthand and to illustrate their differences in terms of what the closure argument is. I'll leave the more prescriptive point about whether one should prefer one spelling or another for the type to others in the future.

@xwu
Copy link
Collaborator Author

xwu commented Oct 19, 2025

@swift-ci smoke test

@xwu
Copy link
Collaborator Author

xwu commented Oct 20, 2025

@stephentyrone Would you or one of the other code owners, and/or the documentation folks, like to weigh in before merge?

@natecook1000
Copy link
Member

Thanks, @xwu – these are great improvements! Re: shortened syntax – that preference is really only when used in type position. When used as an initializer, the documentation style is to prefer the type name (e.g. let fives = Array(repeating: 5, count: 5)), so those examples could be switched back.

I've also requested a review from @amartini51 👍🏻

Copy link
Member

@amartini51 amartini51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor clean-up, but this looks like an improvement to me.

xwu and others added 6 commits October 20, 2025 22:02
Co-authored-by: Alex Martini <amartini@apple.com>
Co-authored-by: Alex Martini <amartini@apple.com>
Co-authored-by: Alex Martini <amartini@apple.com>
Co-authored-by: Alex Martini <amartini@apple.com>
Co-authored-by: Alex Martini <amartini@apple.com>
...adjust line wrapping to account for adoption of prior suggestions, and some minor edits.
@xwu
Copy link
Collaborator Author

xwu commented Oct 21, 2025

@swift-ci smoke test

@xwu xwu enabled auto-merge (squash) October 21, 2025 02:47
@xwu

This comment was marked as outdated.

@xwu
Copy link
Collaborator Author

xwu commented Oct 21, 2025

@swift-ci smoke test Windows platform

@xwu

This comment was marked as outdated.

@xwu

This comment was marked as outdated.

@xwu
Copy link
Collaborator Author

xwu commented Oct 22, 2025

@swift-ci please clean smoke test macos platform

@xwu xwu merged commit a9df691 into main Oct 22, 2025
3 of 4 checks passed
@xwu xwu deleted the inline-array-doc-comment branch October 22, 2025 21:18
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.

4 participants