On Monday, 28 April 2014 at 07:45:20 UTC, Temtaime wrote:
I think he meant next:
A.d:
void foo();
A.cpp:
namespace A { void foo(); }
And now we has:
exnern(C++, A) void foo();
import A;
void main() {
A.foo(); // which foo will be called ? how to call d version or
c++ ?
}
This is close. Forgive inaccurate syntax, but I see at least
these issues that will make namespaces/module-system broken in
terms of maintenance:
YEAR 2014:
framework1.d:
extern (C++, std){ void something(); }
framework2.d:
extern (C++,std){void something(); void anything();}
application.d:
import framework1;
import framework2;
… std.something(); // is this ok, because the extern signatures
match?
---------
YEAR 2015:
std.d is updated:
void something(){}
void coolstuff(){}
application.d is updated to use the new coolstuff():
import framework1;
import framework2;
import.std();
… std.something(); // namespace encapsulation broken or fail?
… std.coolstuff();
application.d is corrected to (or using some other resolution):
import framework1;
import framework2;
import.std();
… framework2.std.something();
… std.coolstuff();
---
YEAR 2016:
framework2.d is modified:
extern (C++,std){ void anything(); }
application.d is recompiled unmodified:
import framework1;
import framework2;
import.std();
// fails even though the signature is still in framework1
… framework2.std.something();
… std.coolstuff();
There's no linker problem because D and C++ has different name
mangling.
Right, but I want to be sure that the type-system sees all
externs with the same signature as the same type. I also am not
sure how the "closing of namespaces" will work if you have
multiple frameworks that independently specify their own C++
bindings to the same library.
The sole purpose of namespace/modules is to have clean separation
between frameworks and support evolutionary development. I am not
convinced that this property is not broken with the proposed
change.
To get around this you will have to remove the "closing of
namespaces" restriction and add a root "cpp" so that all cpp
namespaces get: cpp.std.something() etc…