Make imports private by default

Frank Benoit benoit__ at __tionex.de
Thu Apr 13 05:01:30 PDT 2006


> I never understood why people use private imports .. just what the hell
> is the point?
> Please give real, concrete examples, not just theories/talk.
> "Clogging up the namespace" doesn't say anything meaningful to me.

If you do not care about what is imported, why not make an
import *;
by default and everything is OK?

No, thats not true.
E.g. you make an own class Thread. If every module uses public imports,
you will have a good chance std.thread is indirectly imported. So you
have to use full qualified names all the time. If not it can happen you
use the wrong Thread class. Only because you imported for e.g. std.math
(don't know, sort of example) which imports std.stdio, which imports
..... std.thread. You know what i am trying to say?

The other thing is, that the compiler has this problem with ambiguity of
indirectly imported symbols. Well, last time I run into that problem in
december 05. After that i learned to use private imports.

If you have existing code and make a refactoring in private methods and
decide to remove imports, you can get compile errors in completely other
modules. This is because these module never imported the needed module,
instead they were imported indirectly. I personally want to know, what
is imported from my module.




More information about the Digitalmars-d mailing list