Our template emission strategy is broken
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 11 22:15:00 PST 2015
On 11/11/2015 4:16 PM, Iain Buclaw via Digitalmars-d wrote:
> The main problem for seamless support is having some way to generate the C++
> typeinfo in D to allow work across boundaries.
I suspect that is unnecessary.
The whole point of D's C++ interface is to interface with C++ code. Defining C++
classes in D code that does not link to any C++ code that also defines those
classes won't be supported. I.e. we can reply on the C++ code generating the
necessary C++ typeinfo. The generated D code only has to link to it, i.e.
generate an extern reference to the name of the typeinfo.
Similarly, we never need to throw a C++ exception from D code. All we need to do
is call a library function written in C++ that throws it for us.
What D does need to do is support catching an std::exception*, or a class
derived from std::exception. I believe we are on solid ground in not supporting
any other C++ types being thrown.
Nor do I believe we need to catch C++ objects with catch(...). Catching C++
objects will need an explicit catch(std.exception*).
Over time, perhaps it may become apparent that we do need to support more kinds
of C++ types being thrown. But it is not necessary to get this lead brick
airborne, and we shouldn't waste time worrying about it.
More information about the Digitalmars-d
mailing list