www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - does "private import" means "static import" to other modules importing it?

reply Cheng Wei <rivercheng gmail.com> writes:
suppose we have in module A, we have
import B;

Then in module C;

import A;
B.fun1();
B.fun2();

can be compiled successfully even without "static import B".

Is this correct? Thanks.
Oct 13 2011
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
You can always qualify the full name unless you're importing a
specific symbol, e.g.:

module A;
import B : fun1;

module C;
import A;
fun1();  // ok
B.fun1(); // not ok
B.fun2(); // not ok

static import just means you can't use the symbol without qualifying
the full package/module name before it:
module A;
static import B;

module C;
import A;
B.fun1();  // ok
B.fun2(); // ok
fun1(); // not ok

I think that should be it.
Oct 13 2011
prev sibling next sibling parent "Nick Sabalausky" <a a.a> writes:
"Cheng Wei" <rivercheng gmail.com> wrote in message 
news:j76dc6$1fcu$1 digitalmars.com...
 does "private import" means "static import" to other modules importing it?

It's not supposed to, but it does at the moment due to a bug.
Oct 13 2011
prev sibling next sibling parent Jesse Phillips <jessekphillips+d gmail.com> writes:
On Thu, 13 Oct 2011 16:21:56 +0200, Andrej Mitrovic wrote:

 You can always qualify the full name unless you're importing a specific
 symbol, e.g.:

No, I'm pretty sure it is just a bug, and one that was recently discussed too. Private imports should not expose their symbols to other modules even if you use a fully qualified name.
Oct 13 2011
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 10/14/11, Jesse Phillips <jessekphillips+d gmail.com> wrote:
 On Thu, 13 Oct 2011 16:21:56 +0200, Andrej Mitrovic wrote:

 You can always qualify the full name unless you're importing a specific
 symbol, e.g.:

No, I'm pretty sure it is just a bug, and one that was recently discussed too. Private imports should not expose their symbols to other modules even if you use a fully qualified name.

Woops, sorry for the slip-up.
Oct 14 2011