Is there any good reason why C++ namespaces are "closed" in D?
Walter Bright
newshound2 at digitalmars.com
Mon Jul 30 08:44:14 UTC 2018
On 7/29/2018 8:05 PM, Manu wrote:
> ab.d
> ------
> module ab;
> extern(C++, "ab") void foo();
>
>
> cd.d
> ------
> module cd;
> extern(C++, "cd") void foo();
>
> Perfect!
extern(C++, ab) void foo();
extern(C++, cd) void foo();
Perfect!
struct S1 { extern(C++, ns) void foo(); } alias foo = S1.ns.foo;
struct S2 { extern(C++, ns) void bar(); } alias bar = S2.ns.bar;
Perfect!
> We have what already exists, that can't go away now, but please just give us
> string namespaces as a mangle-only option. Not only will I shut up about it
> forever, but we will also be able to specify namespaces that conflict with D
> keywords, and also organise our modules just like all other D code ever.
I'm the one that gets stuck with the fallout from bad designs. The solution I
proposed above will work for you as best as I can tell. And it works right now,
you don't have to wait for another version.
---
You haven't explained why you can't just move the namespace ns declarations in
one file together. C++ code is organized based on the wretched
no-forward-references problem which doesn't exist in D.
More information about the Digitalmars-d
mailing list