const(Class) is mangled as Class const* const
kinke via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 28 01:30:43 PDT 2017
On Tuesday, 28 March 2017 at 02:14:25 UTC, Jonathan M Davis wrote:
> Realistically, unless D fully supports C++ (which pretty much
> means that it has to become C++ on some level), you're almost
> always going to be stuck with some sort of glue layer between D
> code and C++ code. There's no reasonable way around that. We
> can work to improve the situation so that more C++ stuff just
> works when hooking up to D, but we'll never get all the way
> there, because that would mean dragging C++ into D, which we
> really don't want.
I know that. I'm just arguing for this tiny change in
C++-mangling of D const object references as a remedy for this
one particular issue out of many wrt. C++ interop.
What I don't get is why it's considered important to have a
matching C++ mangling for templates across D and C++ - what for?
I only care about mangling wrt. interop if I wanna link to some
foreign code, and with templates I can't, so I see absolutely no
problem with a D template `extern (C++) void foo()(const(Object)
arg)` being mangled slightly differently (arg as `const Object*`)
than a C++ template `template <typename T> void foo(const T arg)`
with `T = const Object*` (arg as `const Object* const`).
Don't get me wrong, I don't advocate C++-mangling a D `const(S*)`
for some struct S as `const S*` at all - we're talking
specifically about D class references here, which don't have a
direct C++ analogon, so choosing to C++-mangle them in a special
way sounds absolutely feasible to me.
More information about the Digitalmars-d
mailing list