packageless modules == pure evil?
Unknown W. Brackets
unknown at simplemachines.org
Sun Feb 17 17:34:08 PST 2008
This is because you are adding all directories to the import path
perhaps? For example if you do -I. -Iflat then you might have this problem.
-[Unknown]
Bill Baxter wrote:
> torhu wrote:
>> 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.
>
> The problem that prompted this message was that I had a module called
> just "blas" in one place and was trying to make another module called
> "dflat.blas". But that breaks plain "import blas". It picks up the
> "dflat.blas" rather than the packageless blas, even though I didn't
> specify that I wanted "dflat.blas".
>
>>> (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.
>
> But the top-level package may be special. I don't think there's a
> module called "tango" in Tango, is there?
>
> --bb
More information about the Digitalmars-d-learn
mailing list