bevy/examples/reflection
Gino Valente 2b4180ca8f
bevy_reflect: Function reflection terminology refactor (#14813)
# Objective

One of the changes in #14704 made `DynamicFunction` effectively the same
as `DynamicClosure<'static>`. This change meant that the de facto
function type would likely be `DynamicClosure<'static>` instead of the
intended `DynamicFunction`, since the former is much more flexible.

We _could_ explore ways of making `DynamicFunction` implement `Copy`
using some unsafe code, but it likely wouldn't be worth it. And users
would likely still reach for the convenience of
`DynamicClosure<'static>` over the copy-ability of `DynamicFunction`.

The goal of this PR is to fix this confusion between the two types.

## Solution

Firstly, the `DynamicFunction` type was removed. Again, it was no
different than `DynamicClosure<'static>` so it wasn't a huge deal to
remove.

Secondly, `DynamicClosure<'env>` and `DynamicClosureMut<'env>` were
renamed to `DynamicFunction<'env>` and `DynamicFunctionMut<'env>`,
respectively.

Yes, we still ultimately kept the naming of `DynamicFunction`, but
changed its behavior to that of `DynamicClosure<'env>`. We need a term
to refer to both functions and closures, and "function" was the best
option.


[Originally](https://discord.com/channels/691052431525675048/1002362493634629796/1274091992162242710),
I was going to go with "callable" as the replacement term to encompass
both functions and closures (e.g. `DynamciCallable<'env>`). However, it
was
[suggested](https://discord.com/channels/691052431525675048/1002362493634629796/1274653581777047625)
by @SkiFire13 that the simpler "function" term could be used instead.

While "callable" is perhaps the better umbrella term—being truly
ambiguous over functions and closures— "function" is more familiar, used
more often, easier to discover, and is subjectively just
"better-sounding".

## Testing

Most changes are purely swapping type names or updating documentation,
but you can verify everything still works by running the following
command:

```
cargo test --package bevy_reflect
```
2024-08-19 21:52:36 +00:00
..
custom_attributes.rs bevy_reflect: Custom attributes (#11659) 2024-05-20 19:30:21 +00:00
dynamic_types.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
function_reflection.rs bevy_reflect: Function reflection terminology refactor (#14813) 2024-08-19 21:52:36 +00:00
generic_reflection.rs bevy_reflect: Recursive registration (#5781) 2024-03-04 19:04:10 +00:00
reflection.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
reflection_types.rs reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
type_data.rs examples: Add Type Data reflection example (#13903) 2024-07-15 14:19:50 +00:00