Flat module import namespace causing collisions

Timon Gehr timon.gehr at gmx.ch
Thu Feb 16 08:06:22 PST 2012


On 02/16/2012 02:03 PM, Artur Skawina wrote:
> If you have a library with several modules, accessible with eg
> "import lib.blah;" what happens if you try to use this lib module
> from your app placed in a blah.d file?
>
> blah.d:6: Error: module blah from file lib/blah.d conflicts with another module blah from file blah.d
>
> IOW, the default flat namespace is a really bad idea.
> Adding a "module lib.blah'" line to lib/blah.d makes things work, but
> shouldn't be necessary; is there a reason why "import" is stripping
> everything but the basename?
> For non-renamed imports accessing the module (which should be rare)
> using the full name (lib.blah in this case) will be enough.
>
> artur

I agree that it is a poor default. Is it in the spec?


More information about the Digitalmars-d mailing list