Allow use to import declarations into the current namespace, like in Rust#25
Open
Allow use to import declarations into the current namespace, like in Rust#25
use to import declarations into the current namespace, like in Rust#25Conversation
Contributor
|
Is the parent scope/module visible by default or do we have to use E.g., fn foo() = 42;
mod bar {
fn sup() {
let v = foo();
v
}
} |
Contributor
Author
|
No, but this is also the behavior of Rust actually... https://godbolt.org/z/MxqP15sEn I nonetheless have a patch that allows for this. I'm tempted to allow ourselves to diverge from Rust here, and allow for that, but we should probably discuss this on call or on Discord at least. |
|
Typically in rust you would just do a |
Contributor
|
Seems like it is the standard in Rust, so I would say we stick to the default. |
56bd3c4 to
a51f8be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Artic introduced module support a couple years ago, unfortunately it has not seen much adoption.
The oft-cited reason by would-be users is that this module support lacks the ability to import definitions into a namespace, which makes using declarations from others prohibitively verbose (at a minimum you must use a single-letter import like
A::).This PR changes the use syntax to be closer to Rust's, which allow:
use A::*use A::{b, c}