Selective and renamed imports
Fawzi Mohamed
fawzi at gmx.ch
Wed Oct 19 03:24:52 PDT 2011
I think that the treatment of normal and private imports in the patch proposed is the correct one.
Importing should be hidden, this is also basically what LDC 1 does, as it is much more strict on indirect imports.
Public imports on the other hand should be roughly equivalent to declaring the things in the module the imports them.
To be more precise they should be *exactly* equivalent to a private import + alias for all the imported things.
Being selective or renaming in my opinion should not be connected with outside visibility, that should be controlled with public/private.
There is indeed a difference between import and selective or renamed imports, and plain full module imports.
Those are imported with the goal of being used, thus one should check for collisions.
The solution is to make
import x: y, a=z;
public import m1;
public import m2: t, t2=r;
which is equivalent to
private import x: y, a=z;
public import m1;
public import m2: t, t2=r;
equivalent to
import x;
private alias x.y y;
private alias x.z a;
import m1;
public alias m1.* *; // this is a shortcut to mean public aliases to all things declared in m1
import m2;
public alias m2.t t;
public alias m2.r t2;
and privately exported symbols should never be visible when imported again.
I think that this is a semantic that makes sense, and looks natural, and piggybacks on already defined concepts.
Fawzi
More information about the Digitalmars-d
mailing list