Skip to content

Propose RigidArray and UniqueArray#3202

Open
Azoy wants to merge 11 commits intoswiftlang:mainfrom
Azoy:uniquearray
Open

Propose RigidArray and UniqueArray#3202
Azoy wants to merge 11 commits intoswiftlang:mainfrom
Azoy:uniquearray

Conversation

@Azoy
Copy link
Copy Markdown
Contributor

@Azoy Azoy commented Mar 19, 2026

No description provided.

Azoy added 2 commits March 19, 2026 12:47
wip

Update nnnn-rigidarray-uniquearray.md

Update nnnn-rigidarray-uniquearray.md

Update nnnn-rigidarray-uniquearray.md

Update nnnn-rigidarray-uniquearray.md

Update nnnn-rigidarray-uniquearray.md

Update nnnn-rigidarray-uniquearray.md
Azoy and others added 4 commits March 23, 2026 09:59
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
Co-authored-by: Ben Rimmington <me@benrimmington.com>
@rjmccall rjmccall added LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document labels Mar 23, 2026
For example, we could have mutations trigger a runtime error, or we could add
new arguments to mutations that describe specifically how to clone elements.
In practice, neither of these options lead to an acceptable programming
experience.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not? We don't need a big explanation here, but a sentence of explanation would be much stronger than just handwaving it away.

/// Copy the contents of this array into a newly allocated {rigid|unique} array
/// instance with just enough capacity to hold all its elements.
///
/// - Complexity: O(`count`)
Copy link
Copy Markdown
Contributor

@stephentyrone stephentyrone Apr 7, 2026

Choose a reason for hiding this comment

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

Am I inferring correctly that the clone has capacity == count (i.e. any tail capacity is not cloned)? This is what the docs appear to promise, but it is slightly weird that two "clones" do not behave the same.

Either way, the doc comment should be a little more explicit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Am I inferring correctly that the clone has capacity == count (i.e. any tail capacity is not cloned)?

That is currently what the implementation does yes.

/// - Parameter capacity: The desired capacity of the resulting {rigid|unique} array.
/// `capacity` must be greater than or equal to `count`.
///
/// - Complexity: O(`count`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Complexity is potentially O(capacity) on a platform where the underlying allocator eagerly initializes. This may not matter for the purposes of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants