Make imports private by default
Chris Miller
chris at dprogramming.com
Thu Apr 13 10:10:31 PDT 2006
On Thu, 13 Apr 2006 12:29:27 -0400, Bruno Medeiros
<brunodomedeirosATgmail at SPAM.com> wrote:
> Frank Benoit wrote:
>> There was a posting of Tyro
>> http://www.digitalmars.com/d/archives/digitalmars/D/11081.html
>> Most ppl seconded that.
>> The problem is, that D does not work if you use non-private imports all
>> the time. Suddenly there are conflicts.
>> A public import make the imported module part of this modules
>> interface.
>> This can (and should) be made public explicitely.
>>
>
> Totally agree.
>
> As for the consistency issue, it was said private imports by default
> where worth the small inconsistency (of everything else being public).
> Actually I disagree with that at the premise level: I don't think it
> would be an inconsistency at all. Imports are not members of the module,
> as they do not even define a new entity. They are not a "part of" the
> module, they are more like a characteristic of it.
> Further indication is that there is no "package import". And even
> "public import", would it be of any significant use?
>
> (Of course one could think of imports as the definition of a set of
> aliases, but really, I would think that's an unadequate and contrived
> conceptualization)
>
Good point. Perhaps the current private import should be the default, and
to achieve the current public import, something else could be used, such
as "static import" ?
Since the majority of imports are private, and even some public ones
should have been private, I don't think this change would be difficult.
The most common case would then be:
* Default, logical choice;
* Easier to type;
* Better looking code;
More information about the Digitalmars-d
mailing list