Flat module import namespace causing collisions

Timon Gehr timon.gehr at gmx.ch
Thu Feb 16 08:14:02 PST 2012

On 02/16/2012 02:25 PM, James Miller wrote:
> I'm not sure if I'm reading this right... You aren't very clear...
> I think its just because putting a single `module` statement in a file
> is good practice. Its a single line and makes you think about your
> layout and structure.
> Also, there is no global namespace in D, so it must create a module
> level namespace for your file if you don't specify one. No matter what
> scheme you use, it will upset somebody, so they use whatever they
> currently use, and any conflicts are solved by manually setting the
> module name.
> What seems like a bad idea to you could be a great idea to someone
> else, and what seems like a good solution to you will probably upset
> somebody else. There is a way to deal with this "problem", and its not
> even difficult to do, you seem to be a man in search of a problem.
> --
> James Miller

This is a strong claim for someone who is not sure if they understand 
the problem.

Consider the following directory structure:

- a.d
+ b
   - a.d

$ cat a.d
import b.a;
$ cat b/a.d
void someusefulfunction(){writeln("hello world");}
$ dmd a.d
a.d(2): Error: module a from file b/a.d conflicts with another module a 
from file a.d

I don't think this is perfect.

More information about the Digitalmars-d mailing list