Specifying C++ symbols in C++ namespaces

Mason McGill mmcgill at caltech.edu
Thu Apr 3 23:59:40 PDT 2014


"Walter Bright"  wrote in message 
news:lhi1lt$269h$1 at digitalmars.com...
> Here's Andrei's proposal:
>
>     extern (C++) template nspace() {
>         int foo();
>     }
This seems misleading to readers of future code.
- An "extern (C++)" function lets you use a C++ function.
- An "extern (C++)" interface lets you use a C++ interface 
(declared as a class, as is always the case in C++).
- An "extern (C++)" template lets you use a C++... namespace?

On Thursday, 3 April 2014 at 11:19:53 UTC, Daniel Murphy wrote:
> Why not just
>
> pragma(cpp_namespace, "outer")
> {
>    pragma(cpp_namespace, "inner")
>    {
>        extern(C++) void func();
>    }
> }
This really has only one obvious interpretation (the correct 
one), and seems to be a rather harmless addition to the language.

It also fulfills the goal of allowing access to C++ libraries 
without cluttering D with C++ language features.  I don't want to 
have to explain to my students the difference between "modules" 
"D templates" and "C++ namespace templates" (it reminds me of 
old- and new-style classes in Python 2).


More information about the Digitalmars-d mailing list