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

Eliminate use of glob imports in examples #1721

Closed
alice-i-cecile opened this issue Mar 22, 2021 · 4 comments
Closed

Eliminate use of glob imports in examples #1721

alice-i-cecile opened this issue Mar 22, 2021 · 4 comments
Labels
C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

Glob imports (aka `use bevy::prelude::*) are very convenient in real games, especially simple ones.

However, in example code, it makes it very hard to understand where imports are coming from (and risks running into namespace mangling when the boilerplate is used in real code).

What solution would you like?

Replace glob imports in the examples with explicit imports. Do not import from the prelude (or other re-exported locations), instead use full paths so users can find the original location.

This rule should be ignored in the games example folder and the Bevy book. The increased brevity / lowered conceptual overhead is more valuable there.

What alternative(s) have you considered?

Use github1s.com + go to definition to track down the places where the functions are actually defined. This is only a workaround.

Additional context

Related to #1247.

Discussed on Discord here.

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples D-Trivial Nice and easy! A great choice to get started with Bevy labels Mar 22, 2021
@mockersf
Copy link
Member

I think it's better to keep using the prelude in examples. Switching to explicit imports would bloat them.

To explore, your local IDE/rust-analyzer, github1s.com, https://docs.rs/bevy (or a local build for main) fill that need.

Maybe we could look into deploying a doc build for main somewhere?

@alice-i-cecile
Copy link
Member Author

Maybe we could look into deploying a doc build for main somewhere?

I definitely want this regardless :)

@jpryne
Copy link

jpryne commented Mar 22, 2021

I'm new to Bevy and would be willing to dig into this if it is decided upon.

@alice-i-cecile
Copy link
Member Author

Closing; this needs more discussion per #2047. See #1247 for more conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation C-Examples An addition or correction to our examples D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

No branches or pull requests

3 participants