On 4/26/2014 4:01 AM, Mike wrote:
My search found the following proposals:
[1]
extern (C++, namespace = A.B) {}
Technically, this can work, and I was initially in favor of it. But it just
strikes me as awkward. It may be one of the first things C++ programmers wanting
to use D may have to see, and I don't think it would leave a good impression.
Worse, it implies this will work:
extern (C++, namespace = A.B) { ... declarations ... }
extern (C++, namespace = A.B) { ... more declarations ... }
Which would be very, very awkward to try to make work with D's scope lookup
rules.
[2]
pragma(cpp_namespace, "A.B")
extern(C++) void f() {}
This implies that it only affects the name mangling. There needs to be a scope
created, too.
[3]
@namespace("A")
{
@namespace("B") {}
}
I find nothing to recommend that over:
namespace A
{
namespace B { }
}
The object isn't to flagellate programmers wanting to call their existing C++
library code, which (realistically) is simply not going to be translated to D.
[4]
extern (C++) template A()
{
extern (C++) template B() {}
}
The trouble with that is C++ mangles templates differently than namespaces, and
this would make it impractical to then support calling C++ template functions
with no template arguments.
[5]
DIP61 a 'namespace' keyword
Would you be willing to summarize the merits/shortcomings of each of these in
your opinion?
Thanks for creating this list, it is very helpful.
The big problem with many proposals is they only address name mangling. The
scope lookup must be part of it, else it will not scale.