-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Allow higher order systems #4833
Conversation
/// This trait can be useful for making your own adapters to systems. | ||
/// | ||
/// This should be used in combination with [`ParamSet`] where appropriate 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.
Briefly define higher order systems here.
fn run(&mut self, _input: (), param_value: SystemParamItem< ($($param,)*)>) -> Out { | ||
// Yes, this is strange, but `rustc` fails to compile this impl | ||
// without using this function. It fails to recognise that `func` | ||
// is a function, potentially because of the multiple impls of `FnMut` |
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.
Good to see this comment expanded.
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.
Please add a description of higher order systems to your PR description. I think they're systems that can generate other systems, but other readers won't even be able to guess.
The code changes make sense, and after seeing the doc example I'm super impressed by the expressivity of this design. Very minimal changes required, and I'm excited to see what can be made with this.
Are you planning to rewrite ChainSystem
with this?
Rewriting ChainSystem is the linked PR, which people weren't happy with, mainly due to the dynamic system limitations. We need to think up a nice API for dynamic systems. |
Also add some more doc comments
bors r+ |
# 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.
# 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.
# 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.
Objective
SystemParamFunction
allows this.chain
(which is basically equivalent to map)Solution
SystemParamFunction
to be a safe abstraction overFnMut([In<In>,] ...params)->Out
.SystemParamFunction
should not have been counted as part of our public api before this PR.See also
Changelog
Added
SystemParamFunction
, which can be used to create higher order systems.