Vision for the D language - stabilizing complexity?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 15 03:13:13 PDT 2016


On 7/15/2016 2:34 AM, Shachar Shemesh wrote:
> Const is very far from meaningless in C++. It is an extremely valuable tool in
> turning bugs into compile time errors. That is not something to think lightly of

Unfortunately, C++ const is little more than advisory:

1. no protection against casting away const and changing it anyway
2. no protection against adding 'mutable' members and changing it anyway
3. only good for one level, no way to specify a data structure of generic type T 
as const

> (and, sadly, not something D does very well)

Explain. D fixes C++ faults 1..3.


> In terms of optimizations, there are, indeed, cases where, had const not been
> removable, things could be optimized more. I don't think D has a right to
> complain about C++ in that regard, however.

Of course D does. I had to disable const optimizations in my C++ compiler, which 
is one of the motivations for the way const works in D.



More information about the Digitalmars-d mailing list