On Wednesday, 20 January 2016 at 16:38:19 UTC, Marc Schütz wrote:
// a.d
module a;
extern(C++, ns) {
void fooa();
void bar();
}
// b.d
module b;
extern(C++, ns) {
void foob();
}
void bar();
// main.d
import a, b;
void main() {
fooa(); // ok
foob(); // ok
bar(); // Error: b.bar at b.d(6) conflicts with
a.ns.bar at a.d(5)
// let's try to disambiguate: we want ns.bar
ns.bar(); // Error: a.ns at a.d(3) conflicts with b.ns at
b.d(3)
a.ns.bar(); // works, but requires superfluous `a`, even
though
// `ns` already makes it unambiguous
}
I think the first error is correct:
bar(); // Error: b.bar at b.d(6) conflicts with
a.ns.bar at a.d(5)
So you have two functions bar() one inside 'ns' in module a and
"outside" 'ns' in module b.
Now, the last 2 errors, Mark Schutz said:
a.ns.bar(); // works, but requires superfluous `a`, even
though
// `ns` already makes it unambiguous
Question: What happens if you do this: using "ns1" in "module a"
and "ns2" in "module b" and do:
ns1.bar();
?
Because you can't have more than one namespaces with the same
name in C++, right?
JohnCK.