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

tide tide at tide.tide
Mon Aug 6 18:26:29 UTC 2018


On Sunday, 5 August 2018 at 23:28:06 UTC, Walter Bright wrote:
> On 8/4/2018 12:45 AM, Manu wrote:
>> [...]
> I get it, Manu, you don't find my arguments compelling. You've 
> put these forth before, and I could repeat myself rebutting 
> each. I expect we're at a dead end with that.
>
> But the fact remains, I've shown both you and Atila how to make 
> things work for you, in a hygienic manner, with the language as 
> it is now. For you, it's adding an alias declaration. For 
> Atila, it's a couple lines of boilerplate dpp can add, without 
> disrupting dpp's internal design.

What's your crossplatform workaround if I have a namespace named 
"version" or "package" ?

extern(C++, version) // error
{
     void foo();
}

extern(C++, package) // error
{
     void bar();
}

You also didn't mention your reasoning behind not including a way 
to use const pointers to mutable data. The only workaround that 
exists currently is to rewrite C++ code, which you stated wasn't 
a valid solution you considered for extern(C++).

> I understand you don't want to type in the alias declaration. 
> May I suggest using Atila's dpp? Then you won't have to even 
> look at the output. I also expect that your use cases can help 
> make dpp better, and that would be good for all of us.
>
> ---
>
> P.S. I have no experience with dpp and how it is used. But my 
> experience with translators is that nobody expects to nor wants 
> to look at its output. They just want it to work. And it seems 
> a fact of life that the output of machine translation resists 
> being purty, because what's purty in A never looks purty in B.

How can you suggest DPP then go on to say you've never even used 
it or know how it is even used?





More information about the Digitalmars-d mailing list