Skip to content
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

Generics vs Concrete Types #6

Closed
Bluefinger opened this issue Apr 19, 2023 · 2 comments
Closed

Generics vs Concrete Types #6

Bluefinger opened this issue Apr 19, 2023 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@Bluefinger
Copy link
Owner

After consideration and pondering how to enable interoperability between crates for RNG usage, it becomes clear that there might be difficulty in achieving the necessary tools for querying resources/components in a robust manner.

Generic Types

The problem here is not needing to introduce more dependencies, doing things like trait queries. However, the ability to define a custom RNG algorithm might be important for particular use-cases where higher quality/secure entropy must be used, limited within app code or non-interoperable plugin code. In these cases, cross-plugin determinism is likely not going to be the priority, instead only being local determinism (for testing purposes).

Concrete Types

In most cases, devs are likely not going to care about the algorithms, just that either the RNG is fast or secure. Concrete types remove the need for trait queries and simplify the process for a plugin to determine whether a global resource or a component is available. It becomes much easier to write code to make use of a global source or fallback to a non-deterministic default.

Both types could live in the crate, but their use-cases will be separate. Documentation should provide the cases for each and what bevy plugin authors should rely on for interoperability.

@Bluefinger Bluefinger added enhancement New feature or request question Further information is requested labels Apr 19, 2023
@Bluefinger
Copy link
Owner Author

Due to bevyengine/bevy#7184, the resolution of this question is basically to force bevy_rand towards more concrete types instead of generics. TypePath requirements would basically require folks to manually newtype and implement TypePath on said newtype in order to get it to plug in to the generic component successfully, whereas a concrete type will avoid that pain altogether.

As such, I'm considering this question resolved.

@Bluefinger
Copy link
Owner Author

With reflection issues resolved and I feel the current API is stable enough to not warrant further exploration, I'm going to mark this question as closed/solved. In the end, the Generic Type approach works nicely enough, and does not warrant changing to something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant