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

Daniel N no at public.email
Tue Aug 7 08:10:16 UTC 2018


On Tuesday, 7 August 2018 at 02:25:32 UTC, Walter Bright wrote:
> Let's see if we can find some common ground.
>
> The boilerplate I suggested seems to enable DPP to generate 
> working code that behaves "as if" the namespace scope is not 
> there, even for nested namespaces.
>
> Is this correct?

Almost.

extern(C++, noise1.noise2.noise3)
void fun();
alias fun = noise1.noise2.noise3.fun;
void main() { fun(1); }

                    Except the full name bleeds to the user
                                      |
                                      |
                                      V
my.d(4): Error: function my.noise1.noise2.noise3.fun() is not 
callable using argument types (int)

Would you prefer to:
1) Keep as is, let it bleed
2) Suppress namespaces when printing error messages
3) Never generate the namespace in the first-place



More information about the Digitalmars-d mailing list