Why do we have transitive const, again?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Sep 24 19:51:17 PDT 2011


On 9/24/11 9:07 PM, Peter Alexander wrote:
> Heading off on a tangent here, but isn't the const this(this) problem a
> language problem rather than a QoI problem?

The design exists but the implementation has not yet been finalized yet. 
Walter and I have taken the design to a conclusion at least two times, sigh.

> Also, what's wrong with const-correctness on Object? All its methods are
> non-const as they should be. If you made, for example, toHash() const
> then you wouldn't be able to cache the hash, and that's *definitely*
> something people will want to do in many situations. Same goes for
> toString and opCmp/opEquals.

All of these methods must have both const and non-const variants. The 
non-const variant forwards by default to the const one.


Andrei



More information about the Digitalmars-d mailing list