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

Rename bevy_reflect Array to Sequence #7110

Conversation

stefanmitic
Copy link

Renamed bevy_reflect Array to Sequence and all associated types, traits and functions.
Fixed accompanying documentation, tests and examples.

Objective

Fixes #7059

Solution

Renamed Array to Sequence and made sure it is propagated where needed.


Changelog

Changed

bevy_reflect::Array to bevy_reflect::Sequence

…ts and functions.

Fixed accompanying documentation.
@jakobhellermann
Copy link
Contributor

We have List for "linear homogenous collection of elements, length can be changed" and Array for "linear homogenous collection of elements, length cannot be changed", right?

What makes Sequence a better name for the latter? Sequence sounds like something that both array and list would be, "iterable with fixed order, possibly no arbitrary indexing".

@soqb
Copy link
Contributor

soqb commented Jan 6, 2023

What makes Sequence a better name for the latter? Sequence sounds like something that both array and list would be, "iterable with fixed order, possibly no arbitrary indexing".

Array implies "length cannot be changed", but its length can be changed. Lists implement Array so a function taking dyn Array cannot be sure its length will never change.

i agree that Sequence is an awkward choice for the rename and agree with your definition. i'm advising against the renaming until we come up with a better alternative.

@jakobhellermann
Copy link
Contributor

Array implies "length cannot be changed", but its length can be changed. Lists implement Array so a function taking dyn Array cannot be sure its length will never change

Good point. I guess this depends on how we interpret it. A list can be locally treated as an Array, which just restricts it to not using some methods. If you get a &mut dyn Array, you can be sure that while you have it nobody will change its length. Also with a &dyn Array, but you can have a &dyn List and a &dyn Array at the same time. But dyn Array is not a proof of the fact that the underlying array will have the same length at all points in time.
It's like how &T doesn't mean that the underlying storage will never get changed, just that it can be locally treated as read-only (until the lifetime runs out).

@alice-i-cecile alice-i-cecile added A-Reflection Runtime information about types M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jan 6, 2023
@MrGVSV
Copy link
Member

MrGVSV commented Jan 7, 2023

I just left a comment on the original issue. I think another potential fix for the whole "fixed length" problem could be to just separate the two traits (and keeping the name Array).

@stefanmitic
Copy link
Author

I think I can try and bang the code for the new approach out in the next few days, depending on free time.
Should we close this PR then?

@MrGVSV
Copy link
Member

MrGVSV commented Jan 9, 2023

Should we close this PR then?

Maybe leave it open until the new PR is up so we can compare? Or at least until we get more feedback on the new issue?

@alice-i-cecile
Copy link
Member

Closing in favor of the approach in #7121, which I think we agree is clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

rename bevy_reflect's Array
5 participants