Namespaces like C++

Andrey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 16 11:32:29 PST 2017


On Monday, 16 January 2017 at 19:17:57 UTC, Mike Parker wrote:
> D namespaces generally follow the format [package 
> names].moduleName.Type. So to have ui.Manager, then either the 
> module, not the package, needs to be named 'ui', or you need to 
> do the following:
>
> // file ui/package.d
> module ui;
> public import ui.manager;
>
> // file ui/manager.d
> module ui.manager;
> class Manager {}
>
> Then you should be able to use ui.Manager and bypass the module 
> name. The alternatives of static and named imports also work, 
> but they need to be repeated in every module in which you want 
> to use them.

Thanks! That did the trick!


More information about the Digitalmars-d-learn mailing list