Head Const
Jakob Ovrum via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 18 00:10:21 PST 2016
On Wednesday, 17 February 2016 at 22:01:45 UTC, Walter Bright
wrote:
> On 2/17/2016 4:03 AM, Jakob Ovrum wrote:
>> How about disallowing immutable data with extern(C++) types?
>> With extern(C++)
>> data always mutable, `const` could safely be reused to mean
>> C++ const in
>> bindings. Any `mutable`-style code would be implemented in C++.
>
> That doesn't help with trying to match the mangling for:
>
> mutable pointer to const pointer to mutable pointer to const
> pointer to mutable pointer to void
Oh yeah, I totally forgot about that.
> It's still an interesting idea, but it would precluded passing
> any D immutable data structures to C++ code. I tend to think
> such needs to be possible, with the proviso that you'd have to
> verify that the C++ end did not violate the immutability rules.
> It's normal practice to write C++ code as if const were
> transitive.
It's a sizeable sacrifice. I thought maybe it could be worth it
for a simple and consistent implementation, but without
syntactical support for `char * const` mangling it's
substantially less appealing.
More information about the Digitalmars-d
mailing list