Is anything private by default when declared in a module?

Jonathan M Davis jmdavisProg at gmx.com
Mon Dec 2 23:34:26 PST 2013


On Monday, December 02, 2013 13:09:06 H. S. Teoh wrote:
> On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:
> > On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:
> > >On Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:
> > >>Is anything private by default when declared in a module?
> > >
> > >I believe imports only. "import foo;" is private, so you write
> > >"public import foo;" to expose outside. But other than that, I'm
> > >pretty sure everything is public unless you say otherwise.
> > 
> > But sadly named imports aren't private...
> > 
> > /// module foo
> > private import std.stdio: writeln;
> > 
> > writeln can be used in any module which imports foo. :/
> 
> WAT?
> 
> That's messed up. Is there a bug for that?

Yes. It's a longstanding bug with regards to selective imports. They create a 
conflicting symbol in the importing module's scope. That's why you should never 
use them at this point.

https://d.puremagic.com/issues/show_bug.cgi?id=314

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list