Is there any good reason why C++ namespaces are "closed" in D?
Walter Bright
newshound2 at digitalmars.com
Mon Jul 30 08:15:54 UTC 2018
On 7/29/2018 9:53 PM, Manu wrote:
> On Sun, 29 Jul 2018 at 20:25, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>>
>> On 7/29/2018 7:50 PM, Nicholas Wilson wrote:
>>> No it doesn't.
>>
>> I meant that you can today "reopen" namespace scopes by placing them in separate
>> modules.
>
> That's not the same thing... you can create a _different one_ with the
> same name in a different module.
That's right, I've said that before, and that's why I put "reopen" in quotes.
> If you import both modules, the namespaces conflict, so it's
> definitely not 'reopening' it as such.
No, they do not conflict. They are qualified by the module name, for exactly the
same reason you can have the same name in different modules. And, as I posted
before, 'alias' can be used to reference the name(s) as if they were in the
current scope.
> You need to make sure to not name the namespace when specifying
> symbols when you import 2 C++ modules, because it becomes ambiguous.
Again, use qualification or an alias, just like is done with D names already.
More information about the Digitalmars-d
mailing list