Specifying C++ symbols in C++ namespaces

Simen Kjærås simen.kjaras at gmail.com
Fri Apr 4 12:33:24 PDT 2014


On 04.04.2014 20:54, Dicebot wrote:
> On Friday, 4 April 2014 at 18:51:21 UTC, Simen Kjærås wrote:
>> I have to say I like Robert Clipsham's idea best:
>>
>> extern(C++) module nspace {
>>     int foo(); // Is this also extern(C++)? I think it should be.
>> }
>>
>> extern(C++) module nspace {
>>     module innernspace {
>>         int bar(); // Also extern(C++), if we follow the example above.
>>     }
>> }
>
> All solutions based on binding extern(C++) to some D qualification entity are
> bad because they confuse reader into thinking that `bar` is actually
> `nspace.innerspace.bar` and that should never happen.

I'm not entirely sure I follow you here. Is this what you mean?

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

void main() {
     foo();        // Either this does not work, (#1)
     nspace.foo(); // or this does not work.     (#2)
}

If so, is that really bad? I'd say the better choice is to make #2 work, as then 
#1 can be made to work with a simple alias:

alias foo = nspace.foo;

If I'm far off into the fields of ignorance now, care to show me the way to a 
better understanding?

-- 
   Simen


More information about the Digitalmars-d mailing list