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

[Wildcard Variables][spec] _ in imports #3799

Closed
kallentu opened this issue May 13, 2024 · 2 comments
Closed

[Wildcard Variables][spec] _ in imports #3799

kallentu opened this issue May 13, 2024 · 2 comments
Assignees
Labels
feature-completeness A special or edge case of another feature which isn't supported wildcard-variables The wildcard-variables feature

Comments

@kallentu
Copy link
Member

Do we allow an import statement like import ... as _;? And if so, what does this do? Is this also non-binding?

@dart-lang/language-team

Previous Discussion

Maybe we should make _ non-binding as an import prefix?

It's like a top-level declaration, but it's also only available in the lexical scope. If you want to import a library only for it's extensions, you may want to import it with a prefix, and never need to refer to it, and as _ would work for that.

Originally posted by @lrhn in #3791

@kallentu kallentu added the feature-completeness A special or edge case of another feature which isn't supported label May 13, 2024
@eernstg
Copy link
Member

eernstg commented May 14, 2024

Make it non-binding such that it can be used to provide access to just the extensions (and possibly other declarations that get a similar treatment, e.g., implicit constructors).

This would make it possible to use import 'a.dart' as _; import 'b.dart' as _; etc. to import a bunch of extensions (and "similar things", if any, but nothing else). We wouldn't have to think about the appropriateness of using _ all over the place as an import prefix (because it doesn't work), and the developer wouldn't have to avoid name clashes among all those _.

Sounds like an OK job for a wildcard.

@kallentu
Copy link
Member Author

Great. Adding a section on the spec. #3819

@kallentu kallentu self-assigned this May 17, 2024
@kallentu kallentu added the wildcard-variables The wildcard-variables feature label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-completeness A special or edge case of another feature which isn't supported wildcard-variables The wildcard-variables feature
Projects
None yet
Development

No branches or pull requests

2 participants