Head Const

karabuta via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 16 10:06:05 PST 2016


On Tuesday, 16 February 2016 at 06:04:42 UTC, Jonathan M Davis 
wrote:
> On Monday, 15 February 2016 at 22:48:16 UTC, Walter Bright 
> wrote:
>> rears its head again :-)
>>
>> Head Const is what C++ has for const, i.e. it is not 
>> transitive, applies to one level only. D has transitive const.
>>
>> What head const will do for us:
>>
>> 1. make it easy to interface to C++ code that uses const, as 
>> currently it is not very practical to do so, you have to 
>> resort to pragma(mangle)
>>
>> 2. supports single assignment style of programming, even if 
>> the data is otherwise mutable
>>
>> The downside is, of course, language complexity.

>
> Previously, you stated that we weren't going to do things like 
> support interacting with C++ templates (aside from specific 
> instantiations which weren't typed as templates), because it 
> would mean putting a C++ compiler into D, which you didn't want 
> to do. But increasingly, it seems like you're heading in the 
> direction of doing that in an attempt to be able to have 
> fantastic C++ interoperability. On the one on hand, that seems 
> great, since being able to have your C++ code work with your D 
> code is great, but on the other, it seems like it's going to 
> make it so that D is contaminated by a lot of extra C++ muck 
> just to be able to interoperate. At some point, we either need 
> to decide that we're just not going to interoperate with C++ in 
> some manner and lose out on some capability, or we're going to 
> need to fully interoperate with C++ and pretty much put a C++ 
> compiler in the D compiler, and I'd prefer that we didn't go 
> that far.
>
> - Jonathan M Davis

Hahaha. Well, I think it is already happening. Like the 
reincarnation of C to C++ story.


More information about the Digitalmars-d mailing list