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 Q type parameter to D when referring to WorldQueryData #10782

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

Nilirad
Copy link
Contributor

@Nilirad Nilirad commented Nov 28, 2023

Objective

Since #10776 split WorldQuery to WorldQueryData and WorldQueryFilter, it should be clear that the query is actually composed of two parts. It is not factually correct to call "query" only the data part. Therefore I suggest to rename the Q parameter to D in Query and related items.

As far as I know, there shouldn't be breaking changes from renaming generic type parameters.

Solution

I used a combination of rust-analyzer go to reference and Ctrl-Fing various patterns to catch as many cases as possible. Hopefully I got them all. Feel free to check if you're concerned of me having missed some.

Notes

This and #10779 have many lines in common, so merging one will cause a lot of merge conflicts to the other.

@Nilirad Nilirad added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change labels Nov 28, 2023
@ItsDoot
Copy link
Contributor

ItsDoot commented Nov 28, 2023

I would even go as far as to recommend using full Data and Filter names for the generic parameters, at least on the Query struct definition: pub struct Query<Data, Filter> {} to make it abundantly clear what each of them mean.

@Nilirad
Copy link
Contributor Author

Nilirad commented Nov 28, 2023

I would even go as far as to recommend using full Data and Filter names for the generic parameters, at least on the Query struct definition: pub struct Query<Data, Filter> {} to make it abundantly clear what each of them mean.

Honestly, I would too, however the convention at the moment is single letter naming.

@alice-i-cecile
Copy link
Member

I'm in favor of this direction. I think we should merge the other PR first though, since it's publicly breaking.

@rlidwka
Copy link
Contributor

rlidwka commented Nov 29, 2023

Honestly, I would too, however the convention at the moment is single letter naming.

Always prefer readability over conventions.

impl<Marker, In, F> Condition<Marker, In> for F {}
impl<A, B, Func> ReadOnlySystem for CombinatorSystem {}
impl<Input, Out, Func: Send + Sync + 'static> ExclusiveSystemParamFunction for Func {}
impl<Param: SystemParam> SystemState<Param> {}

@Nilirad
Copy link
Contributor Author

Nilirad commented Nov 30, 2023

Honestly, I would too, however the convention at the moment is single letter naming.

Always prefer readability over conventions.

impl<Marker, In, F> Condition<Marker, In> for F {}
impl<A, B, Func> ReadOnlySystem for CombinatorSystem {}
impl<Input, Out, Func: Send + Sync + 'static> ExclusiveSystemParamFunction for Func {}
impl<Param: SystemParam> SystemState<Param> {}

That's more common than I thought. What do you think @alice-i-cecile? Should we go right now with full names for type parameters (Data and Filter)?

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Nov 30, 2023

I think we should stick to D and F for now to reduce controversiality. I suspect that the docs / type signatures will be much clearer now that we have good supertraits with clear names.

@Nilirad Nilirad force-pushed the query-data-type-param branch 3 times, most recently from b8a7ba0 to 4fad095 Compare December 5, 2023 18:26
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 13, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 13, 2023
Merged via the queue into bevyengine:main with commit 9c78128 Dec 13, 2023
22 checks passed
@Nilirad Nilirad deleted the query-data-type-param branch December 13, 2023 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants