Head Const

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 24 01:57:51 PST 2016


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.

I think that increasing language complexity for the sake of C++ 
integration is a dubious trade-off, especially since "all" that's 
required is correct name mangling. There's no guarantee of what 
the C++ side can do with any type of constness anyway, I'd say 
that any "extern(C++)" mangles as C++ would and leave it at that.

Atila


More information about the Digitalmars-d mailing list