-
Notifications
You must be signed in to change notification settings - Fork 66
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
World query filter RFC. #58
Conversation
Disallow query filter types that don't make sense as filters, e.g. `&MyComponent`.
I'm in favor of this direction. I think it would add quite a bit of conceptual clarity to the end user, and result in better error messages and more foolproof APIs. The fact that you can use fetch data in filters and vice versa is surprising, and as far as I've seen, is never idiomatically used. |
Thanks Alice! This is probably the fastest RFC review I have ever had, too. |
Can we rule out the reverse mistake too? I've seen users struggle with putting query filters in their fetch argument, only to receive a useless piece of data. My instinct is that this needs two disjoint traits for each argument, each of which relies on a common data-access-defining subtrait. |
Yes we can and my proposal discusses that as a future possibility. But I would prefer to design it separately as there are multiple ways to do it and I don't have a prototype implementation yet, just a couple of ideas. I'll happily do that work if/when this first step is merged. |
Interesting. My instinct is that it would be less painful to reconceptualize and rewrite this code once to account for both changes. That said, your proposed implementation is extremely easy, and my suggestion would not be. |
I had exactly the same instinct, but then I thought of the described trick. The problem with "reconceptualize and rewrite" into "two disjoint traits for each argument, each of which relies on a common data-access-defining subtrait" is that we don't just have the one trait. We have all those helper traits ( |
This PR is a prototype implementaton of bevyengine/rfcs#58 RFC that proposes disallowing using component types as query filters. This PR also introduces `derive(WorldQueryFilter)` proc macro to make custom query filters, analogous to custom queries.
This PR is a prototype implementaton of bevyengine/rfcs#58 RFC that proposes disallowing using component types as query filters. This PR also introduces `derive(WorldQueryFilter)` proc macro to make custom query filters, analogous to custom queries.
Why is this an RFC? This being allowed is clearly a regression, which isn't something which needs an RFC. It appears that this regressed in TheRawMeatball/bevy#48 by @BoxyUwU, which landed as part of bevyengine/bevy#3001. (Fwiw, I don't think we should do the inverse without a replacement (e.g. an |
This is an RFC because it was not clear to me that this is a regression. In fact, to a newby it appears to be a design choice as the Independently of it being a regression, I do believe that codifying it is a good idea. An RFC that documents this part of the ECS API feels necessary, given that there was no RFC and as a result the cited author has broken the back-then-verbal contract.
We should, just not for change detection. For example, |
This is a regression since the latest release I would have thought a regression test would have sufficed in the PR fixing this. As far as I know, this wasn't an intentional break of this contract, just an unconsidered consequence which was snuck in as part of the unreviewable bevyengine/bevy#3001. Therefore, even if this was codified as an RFC before then, it would still probably have landed - that is, this being an RFC is not a good way to achieve that stated goal. I think I agree that |
|
if we do this the "correct" impl is definitely |
Hmm, personally I would rather read code that explicitly states what it does. |
|
In fact, another idea I has was to not split the query and filter at all, like so:
Only the Although I'm not sure it's a good idea. But right now seeing those |
Basically implemented in bevyengine/bevy#9918! |
Disallow query filter types that don't make sense as filters, e.g.
&MyComponent
.Rendered.