Why do we have transitive const, again?

Peter Alexander peter.alexander.au at gmail.com
Sun Sep 25 05:46:27 PDT 2011


On 25/09/11 3:51 AM, Andrei Alexandrescu wrote:
> 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.

That's good to hear. Any possibility of sharing what the design will be?


>> 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.

I think that's a good choice. As long as const isn't forced for those 
operations.



More information about the Digitalmars-d mailing list