Flat module import namespace causing collisions

Artur Skawina art.08.09 at gmail.com
Thu Feb 16 09:44:09 PST 2012

On 02/16/12 17:06, Timon Gehr wrote:
> 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.
> I agree that it is a poor default. Is it in the spec?

Hmm. The module *name* is specified as the basename, but i don't see
anything preventing using "package.module", instead of just "module".


More information about the Digitalmars-d mailing list