packageless modules == pure evil?

torhu no at spam.invalid
Sun Feb 17 11:48:38 PST 2008


Bill Baxter wrote:
> I would just like to confirm with others that this is the case, and also 
> perhaps raise general awareness about the issue.
> 
> The issue is that modules without a package will conflict with a 
> similarly named module in _any_ package.
> 
> So for example if there's a module called "foo" and you import it in 
> your project, then your project absolutely CANNOT have another module 
> named "foo" or "blarf.foo" or /anything/ that ends in ".foo" anywhere in 
> the import chain.
> 
> For this reason it must be concluded that packageless modules are pure 
> evil, and should never ever be used.  Always always give your modules a 
> package even if it's just repeating the module name like "foo.foo".
> 
> Am I right about this?

What kind of conflict do you mean?  Compiler errors or linker errors? 
The only linking problem I've seen is that if you have two modules with 
the same name, the compiler will overwrite one with the other, so only 
one of them gets linked in.  I guess the -op switch to bud or the 
compiler will fix this.  dsss avoids this issue by default, as long as 
you don't have two modules of the same name and both are packageless.

I've come across this issue maybe once, and then I just renamed one of 
the files to fix it.

> (and anyone know if module "foo.bar" will clash with "baz.foo"?)

Tango has packages and modules with the same name, so it should work.


More information about the Digitalmars-d-learn mailing list