DCP Default Private Imports
Difference (last change) (no other diffs, normal page display)
Deleted: 1d0
|
Changed: 4c3
STATUS: Implemented Proposal #1 "Default Private Imports", as of ![]() |
STATUS: Implemented Proposal #1 "Default Private Imports", as of ![]() |
Changed: 24c23
* ![]() |
* ![]() |
Changed: 28c27
* ![]() ![]() |
* ![]() ![]() |
D Change Proposal - Default Private Imports [IMPLEMENTED]
STATUS: Implemented Proposal #1 "Default Private Imports", as of DMD 0.163 (July-2006).
Background & Terminology
[TODO - Explain the issue, what are private and public imports, the transitiveness of non-private imports, etc.]Related/See Also:
Proposal #1 Default Private Imports
- Status: DISCUSSED, IMPLEMENTED
- Note: The following details are dated pre-implementation (DMD 0.163, July-2006).
All import statements which do not have a "protection" attribute should default to private, instead of public.
Main Proposal Thread:
Aditional Discussion:news://news.digitalmars.com:119/e8vvk3$1no9$1@digitaldaemon.com (Subthread, No Archives)
news://news.digitalmars.com:119/e1l9u2$1vvv$1@digitaldaemon.com (
Archives)
It is argued that private imports constitute the vast majority of imports in D code, and as such, for the sake of brevity, they should be the default.
Rationale Against (CONS)
It is argued that such change would be inconsistent, since in all other declarations "public" is the default protection level.
![]() |
|
Some counter arguments: Some members do not agree with this view. It is argued that import is conceptualy significantly different the other D declarations:
- (
news://news.digitalmars.com:119/e90u1h$4no$1@digitaldaemon.com)
- (
news://news.digitalmars.com:119/44B409E6.5060602@nospam.org)
Overall rating: The community at large agrees with this proposal. Only Walter is known to oppose it.
- BrunoMedeiros: In Favor.
Proposal #2 Default Private Everywhere
Status: NOT PROPOSED [I'm mentioning this just for completeness]Description
The default protection attribute for *any* declaration should be private, and not public.
Proposal #3 Separate the Two Import Notions
Status: ALPHA? NOTDISCUSSED? [FIXME]Background
One can think of two separate import notions:
- One, where the imported names are brougth to the current namespace "background" (the "secondary namespace"). Equal names can be imported into the background namespace, and there is a conflict/error only if these names are accessed.
- Two, where the imported names become proper module members, as aliases to their original names/entities. Thus they are brougth to the current namespace "foreground" (the "primary" namespace) and there can be no conflicting names.
Use different language constructs for each of these two import notions, with slighty varying semantics. The first type:
![]() |
|
The second type:
![]() |
|
Notes: This has some implications in the ImportConflictResolution proposals. They can work toghether but it would have to be further detailed how.
Rationale (PROS)
Hum... better conceptualization?