-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Make system chaining use a normal system #4666
Conversation
# Objective - Higher order system could not be created by users. - However, a simple change to `SystemParamFunction` allows this. - Higher order systems in this case mean functions which return systems created using other systems, such as `chain` (which is basically equivalent to map) ## Solution - Change `SystemParamFunction` to be a safe abstraction over `FnMut([In<In>,] ...params)->Out`. - Note that I believe `SystemParamFunction` should not have been counted as part of our public api before this PR. - This is because its only use was an unsafe function without an actionable safety comment. - The safety comment was basically 'call this within bevy code'. - I also believe that there are no external users in its current form. - A quick search on Google and in the discord confirmed this. ## See also - #4666, which uses this and subsumes the example here --- ## Changelog ### Added - `SystemParamFunction`, which can be used to create higher order systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much simpler API, and should significantly simplify working with system chaining elsewhere.
It makes sense that we can do this now that systems as closures is supported.
From @TheRawMeatball on Discord In light of that, I think it's reasonable to block this on the TAIT RFC and the associated Rustlang issue. |
# Objective - Higher order system could not be created by users. - However, a simple change to `SystemParamFunction` allows this. - Higher order systems in this case mean functions which return systems created using other systems, such as `chain` (which is basically equivalent to map) ## Solution - Change `SystemParamFunction` to be a safe abstraction over `FnMut([In<In>,] ...params)->Out`. - Note that I believe `SystemParamFunction` should not have been counted as part of our public api before this PR. - This is because its only use was an unsafe function without an actionable safety comment. - The safety comment was basically 'call this within bevy code'. - I also believe that there are no external users in its current form. - A quick search on Google and in the discord confirmed this. ## See also - bevyengine#4666, which uses this and subsumes the example here --- ## Changelog ### Added - `SystemParamFunction`, which can be used to create higher order systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should swap this back to a method, as GATs have landed 🎉
# Objective - Higher order system could not be created by users. - However, a simple change to `SystemParamFunction` allows this. - Higher order systems in this case mean functions which return systems created using other systems, such as `chain` (which is basically equivalent to map) ## Solution - Change `SystemParamFunction` to be a safe abstraction over `FnMut([In<In>,] ...params)->Out`. - Note that I believe `SystemParamFunction` should not have been counted as part of our public api before this PR. - This is because its only use was an unsafe function without an actionable safety comment. - The safety comment was basically 'call this within bevy code'. - I also believe that there are no external users in its current form. - A quick search on Google and in the discord confirmed this. ## See also - bevyengine#4666, which uses this and subsumes the example here --- ## Changelog ### Added - `SystemParamFunction`, which can be used to create higher order systems.
This is no longer blocked! Want to rebase, or should I stick an Adopt-Me on this? |
Can you clarify what changed to unblock it? |
Stageless merged :) |
I must admit, I'm still not following how that solves the issue that we can't add the chain method without TAIT, unless we do boxing? Was the decision made in stageless to just do the boxing? |
Oh right, I remember this discussion now. Sorry for the confusion. Still blocked unfortunately. |
And, sadly still blocked! Closing as part of backlog cleanup. Feels like the |
Objective
System
trait.Solution
SystemParamFunction
to allow higher-order systems to be created in terms of functions rather than Systems.ChainSystem
to this.Please note, that without GATs, as far as I know, we cannot have
chain
remain as a method. However, GATs are on the path to stabilisation, hopefully in a form sufficiently powerful for this case.Open questions
Is
chain
the correct name? I think it's probably a fine name, but the idiomatic style is for functions which return systems to have the_system
suffix. Do we make an exception forchain
due to the old name or higher-order nature?Changelog
Changed
The
chain
method on system functions has been removed. Use thebevy_ecs::system::chain
function instead (which is in thebevy_ecs
prelude).Migration Guide
The
chain
method on system functions has been removed. Use thebevy_ecs::system::chain
function instead (which is in thebevy_ecs
prelude). If previously you used chain as:you should instead use: