dart-lang / dart-lang/language

Feedback on private imports

Open
#1,809 3 comments 0 reactions 1 assignee Claimed by @munificent View on GitHub
package-libraries
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

The [Packaged Libraries](https://github.com/dart-lang/language/blob/master/working/packaged-libraries/feature-specification.md) proposal includes a section on private imports and includes the following questions / comments.

> __TODO: Better syntax? Allow only importing some private names?__

It would be inconsistent if the language didn't support hiding private names because hiding is one of the primary ways users can deal with conflicting imports. (How common it is in practice, compared to using prefixes, would be an interesting thing to measure.) If we're going to allow hiding individual top-level names then we should be able to show them as well.

If we need to allow individual private names in the `show` clause, then we might want a different syntax for the "show all" case because `_` is a valid private identifier and would hence be ambiguous.

Another possibility would be to _only_ allow showing individual names on the grounds that it's safer than importing everything. It would be interesting to know how many names would need to be shown if they had to be listed explicitly.

> __TODO: We could consider something like #1627 to allow importing only certain private instance members.__

If we were to support hiding and showing instance members for other reasons, then consistency would suggest that we support private members as well. Without it there's a chance that introducing a private method in one library might cause a pre-existing method in a different library to override it, either with or without error. If this could happen across packages I'd say that hiding the unexpectedly overridden member was fairly important, but within a single package it should be fairly easy to rename one of the members.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.