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

Implement Glob Import Feature #3689

Closed
ghost opened this issue Dec 5, 2023 · 2 comments
Closed

Implement Glob Import Feature #3689

ghost opened this issue Dec 5, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Dec 5, 2023

Problem

Current import system requires individual module or function imports, leading to lengthy and cluttered import sections.

Happy Case

Enable use module::*; syntax for importing all items from a module, simplifying code and reducing import lines.

use dep::std::prelude::*;

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@ghost ghost added the enhancement New feature or request label Dec 5, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Dec 5, 2023
@kevaundray
Copy link
Contributor

I generally find glob imports to make the code unreadable and (I could be misremembering) caused quite a few problems in the codebase of rust-analyzer and rustc, I'm guessing because glob imports have different semantics to normal imports. So for example, the following code should compile:

mod foo {
    pub struct Hello;
    pub struct Bye;
}

mod bar {

    use super::foo::*;
    struct Hello {
        a: u8,
    }
    fn baz() {
        let h = Hello;
    }
}

Note that we are using a glob import to import Hello from foo and then we are declaring a Hello in bar. Changing to let h = Hello{ a : 0} should also compile.

If you change use super::foo::*; to use super::foo::Hello; then the code will now not compile because you've imported two items under the Hello namespace

@ghost
Copy link
Author

ghost commented Dec 5, 2023

@kevaundray

Perhaps it shouldn't be introduced as a function for users, but rather as an internal feature? This way, instead of manually specifying https://github.com/noir-lang/noir/pull/3693/files#diff-9ed086179960462bc0c6c2e7dc2594abfbc5f97f4cff55c5421b341cacb1e45aR54 which items need to be imported, we could just import all public items automatically.

@ghost ghost closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Dec 7, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

1 participant