Exclusive system order of parameters shouldn't matter
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Currently, exclusive systems must be declared with a rigid parameter order. I found this confusing because non-exclusive systems are less rigid in their expectations. If possible, exclusive systems should consider being less rigid.
As an example, the following code compiles:
```
pub fn periodic_save_world_state(
world: &mut World,
mut last_save_time: Local,
) { ... }
```
but this code does not compile:
```
pub fn periodic_save_world_state(
mut last_save_time: Local,
world: &mut World,
) { ... }
```
The difference is the order in which the parameters are declared.
## What solution would you like?
I would like both code snippets to compile, or to come away with an understanding of why this isn't desirable.
## What alternative(s) have you considered?
I haven't considered other approaches.
## Additional context
When I write code in Bevy, I come into it with a mindset of "I am writing a system. The system will be provided everything it needs via dependency injection. The system should just declare what it needs as parameters."
and this mindset generally holds.
In past experiences working with DI tools, the order in which I declare parameters is entirely irrelevant. The DI tool sweeps my function declarations, determines the types needed, searches its registry for matching types, and fulfills them.
The fact that I need to adjust my function signature to appease the DI tool is unexpected and undesirable.
Contributor guide
Research direction
Start by reproducing the two `periodic_save_world_state` signatures and tracing how exclusive system parameters are validated. The issue names no files or tests, so locate the exclusive-system parameter handling before deciding whether parameter order can be relaxed. Done means both examples compile, or the restriction is documented with a clear rationale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100