Logical const

Walter Bright newshound2 at digitalmars.com
Tue Nov 30 11:16:22 PST 2010


Max Samukha wrote:
> The problem is that logical const has many perfectly valid use cases. 
> You cannot simply tell people: "Don't use it. It is a fraud".

I am not and never have said "don't use it. It's a fraud." I said that the C++ 
language has no notion of "logical constness", and that it is nothing more than 
a popular convention. The notion that C++ supports logical constness is the fraud.


> They will 
> still be using casts or not using D. As casting away const is undefined 
> behavior in D, the outcome will be every second non-trivial D program 
> relying on undefined behavior.

Yes, it's undefined behavior. That doesn't mean you cannot use it, just that you 
are responsible for getting it right rather than the compiler.


More information about the Digitalmars-d mailing list