Specifying C++ symbols in C++ namespaces

Mike none at none.com
Wed Apr 2 17:23:03 PDT 2014


On Wednesday, 2 April 2014 at 23:04:58 UTC, Mike wrote:
> On Wednesday, 2 April 2014 at 22:06:53 UTC, Walter Bright wrote:
>> Here's Andrei's proposal:
>>
>>    extern (C++) template nspace() {
>>        int foo();
>>    }
>>
> Is this for interfacing D to C++, or a way to bring namespace 
> semantics to D?
>

Well, I'm assuming this is specifically for interfacing D with 
C++ given the 'extern (C++)' attribution.  In that case, I think 
the proposal abuses the 'template' keyword for something that's 
not really a template.

In that case, I find the syntax proposed by bearophile to be far 
better...

extern (C++ nspace) {
     int foo();
}

...although I would even prefer it be even more explicit...

extern (C++ namespace nspace) {
     int foo();
}

I'd also be interested in hearing the arguments against the UDAs 
and pragmas proposed in the following two links:
* https://d.puremagic.com/issues/show_bug.cgi?id=7961
* https://github.com/D-Programming-Language/dmd/pull/2767

The pragma is especially nice since this isn't really a D thing, 
although bearophile's proposed syntax is hard to argue against.

Mike


More information about the Digitalmars-d mailing list