really why module declarations?

XavierAP via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 26 15:10:07 PDT 2017


On Sunday, 26 March 2017 at 20:58:24 UTC, Adam D. Ruppe wrote:
>
> Module declarations are only optional in the most trivial case 
> that is rarely useful in real world code. I recommend you 
> ALWAYS use them (and always put a ddoc comment on them!), and 
> moreover that you avoid top name modules (use 
> `myproject.modname` instead of `modname`) to avoid conflicts.

OK I was already doing it all this in the multi-file project. I 
was curious but I guess it's long to explain the different things 
that can go wrong if one doesn't declare module names.

Followup question: if I am inside module myproj.pack1.mod1 and 
want to import myproj.pack1.mod2... should I import 
myproj.pack1.mod2; or import mod2; ?


More information about the Digitalmars-d-learn mailing list