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

Manu turkeyman at gmail.com
Mon Jul 30 16:45:12 UTC 2018


On Mon, 30 Jul 2018 at 01:45, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> 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.

Sure it 'works', but it's an annoying point of friction, and it
doesn't need to be that way.
It requires over-specification of the namespace at calls, and it
creates friction for scanning meta.
It offers nothing, and only makes things harder and unintuitive.

Why do you have such a strong opinion about a thing that you don't use?
None of the customers ever suggested it should be like it is.
Just let us mangle our symbols! We'll design our modules how we like;
we're not morons, we want to present API's to users in logical and
sensible ways.


> You haven't explained why you can't just move the namespace ns declarations in
> one file together.

Are you serious?

https://github.com/dlang/druntime/pull/2259 <- There, I fixed it for
you. I can't wait to get all the container classes in there too!
If you really believe that, and not just trolling me, then click merge.

Why would I want to have one gigantic module with everything dumped in
it? No end-user wants that.
We just want to use D as it is. What is so bad about D's module system
that you plainly refuse to let us use it as it was intended?

Just allow a string version. It's going to be okay. Everybody will be
happier. The sky won't fall.
When torrents of people complain, you can send every single one of
them to me, tell me "I told you so", and I'll eat my hat.


More information about the Digitalmars-d mailing list