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

Daniel N no at public.email
Thu Aug 2 09:26:41 UTC 2018


On Thursday, 2 August 2018 at 08:31:28 UTC, Walter Bright wrote:
> On 8/1/2018 10:06 PM, Johannes Pfau wrote:
>> I guess that would be acceptable if there is a real benefit, 
>> but I have
>> not seen a single argument for the current behavior in this 
>> thread.
>
> Please read my postings in this thread, then.

I know you have been very patient with explaining this, but I've 
been trying to read all threads on this topic and I'm still not 
sure, can you please acknowledge if I understood you correctly or 
not?

Let's use a simple pseudo example? Let's assume we have two 
different 'any' implementations...

The current extern(c++) design allows us to bind to both of them 
in a single file.

cpp_bindings.d
extern(c++, std)   ...any-definition...
extern(c++, boost) ...any-definition...

Personally I would never *bind* to two different namespaces in a 
single file, are there any other additional benefits to the 
current design which I'm overlooking?

With a non-scoped extern(c++) we could simply use two files.

cppstd/any.d
extern(c++, std)   ...any-definition...

boost/any.d
extern(c++, boost) ...any-definition...

My conclusion is that _if_ I understood you correctly, it must 
mean that in the examples which you have in mind, it is common to 
*bind* to two namespaces in the same file? Could you give a 
real-world examples of two namespaces which you would like to mix 
like that in the same *bindings* file? Is it for instance 'std' 
and 'std::experimental'?



More information about the Digitalmars-d mailing list