On 7/10/2012 4:16 PM, Timon Gehr wrote:
Const is stronger than what is required to bridge the gap between mutable and immutable. It guarantees that a reference cannot be used to mutate the receiver regardless of whether or not the receiver is immutable underneath. That is unnecessary as far as immutable is concerned. It only needs to guarantee that the receiver does not change if it is immutable underneath.
If you have a const function that accepts both mutable and immutable args, then that function *by definition* cannot tell if it received mutable or immutable args.
Furthermore, a const function is saying it will not change, even if mutable data is passed to it.
Everything falls apart once you allow "logical const" in. You'll be in the same boat as C++ const, which is faith-based programming rather than checkable programming.