On Wednesday, 20 January 2016 at 17:25:56 UTC, JohnCK wrote:
On Wednesday, 20 January 2016 at 16:38:19 UTC, Marc Schütz
wrote:
I think the first error is correct:
bar(); // Error: b.bar at b.d(6) conflicts with
a.ns.bar at a.d(5)
Yes, I put this one in to show why the next lines are sometimes
necessary.
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();
?
There'd be no collision anymore, but...
Because you can't have more than one namespaces with the same
name in C++, right?
You can:
namespace ns {
void foo();
}
namespace ns {
void bar();
}
int main() {
ns::bar();
return 0;
}
More realistically, the namespace declarations would appear in
different header files, all #included into the same cpp file.
These different header files would naturally be mapped to
different D modules.