Vision for the D language - stabilizing complexity?

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 15 13:48:59 PDT 2016


On 15/07/16 22:50, Walter Bright wrote:

> You can do logical const in D just like in C++, and get those
> performance gains. You just can't call it "const". But you can call it
> /*logical_const*/ and get the same result.

No, you can't. The fact that the compiler enforces the no const to 
mutable transition (unless you use a cast) is one of the main appeals of 
using const in any language. If you call something "logical const", but 
the compiler does not help you to catch bugs, then I don't see the point.

In effect, if logical const is what you want, C++ gives you a tool while 
D leaves you to your own devices. As a result, a lot of places you'd 
define as const in C++ are defined mutable in D, losing language 
expressiveness.

Shachar


More information about the Digitalmars-d mailing list