Specifying C++ symbols in C++ namespaces

Simen Kjærås simen.kjaras at gmail.com
Fri Apr 4 11:51:02 PDT 2014


On 03.04.2014 00:07, Walter Bright wrote:
> Here's Andrei's proposal:
>
>      extern (C++) template nspace() {
>          int foo();
>      }
>
> It would be accessed in D by:
>
>     nspace!().foo();
>
> A possible enhancement would be to allow (for all templates with no parameters):
>
>      nspace.foo();
>
> Note that:
>
>      template nspace() {
>          extern (C++) int foo();
>      }
>
> would not put foo() in a C++ namespace, although it would still be accessed from
> D as:
>
>      nspace.foo();
>
> One downside of this proposal is that if we ever (perish the thought!) attempted
> to interface to C++ templates, this design would preclude that.

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.
     }
}

I haven't the foggiest idea how C++ modules are supposed to work, so there might 
be clashes with those somehow?

-- 
   Simen


More information about the Digitalmars-d mailing list