Specifying C++ symbols in C++ namespaces

Dejan Lekic dejan.lekic at gmail.com
Mon Apr 7 11:06:23 PDT 2014


On Saturday, 5 April 2014 at 20:47:29 UTC, Walter Bright wrote:
> On 4/2/2014 3:07 PM, Walter Bright wrote:
>> One downside of this proposal is that if we ever (perish the 
>> thought!) attempted
>> to interface to C++ templates, this design would preclude that.
>
> Yes, this seems to be a fatal flaw. Another design that has 
> evolved from these discussions and my discussions with Andrei 
> on it:
>
>     extern (C++, namespace = A.B) { void foo(); void bar(); }
>     extern (C++, namespace = C) void foo();
>
>     bar();  // works
>     A.B.bar(); // works
>     foo(); // error: ambiguous
>     C.foo();   // works
>
>     alias C.foo foo;
>     foo();  // works, calling C.foo()
>
> I really think the namespace semantics should be attached to 
> the extern(C++) rather than be a separate pragma. Having the 
> namespace= thing means that namespace isn't a keyword, and 
> provides a general mechanism where we can add language specific 
> information as necessary.

I actually like this idea the most. It is clean, and easy to 
understand.


More information about the Digitalmars-d mailing list