Is there any good reason why C++ namespaces are "closed" in D?

kinke noone at nowhere.com
Sun Jul 29 12:10:01 UTC 2018


On Sunday, 29 July 2018 at 11:03:43 UTC, Jonathan M Davis wrote:
> I guess that the argument at that point is that you would have 
> to put them in separate D modules, just like you would if they 
> were extern(D) functions.

Yep, that'd sound acceptable to me, implying that

```
extern(C++, cppns) { void foo(); }
void foo();
```

wouldn't work anymore, and particularly, this neither:

```
extern(C++, cppns)
{
     extern(C++, nested) { void foo(); }
     void foo();
}
```

so that a straight C++ namespace => D module hierarchy mapping 
would probably be required in the general case:

```
// cppns/package.d
module cppns;
extern(C++, cppns) { void foo(); }

// cppns/nested/package.d
module cppns.nested;
extern(C++, cppns) extern(C++, nested) { void foo(); }
```



More information about the Digitalmars-d mailing list