const by default.

Sean Kelly sean at f4.ca
Wed Jul 5 12:59:44 PDT 2006


BCS wrote:
> Deewiant wrote:
>>
>>
>> I think there's a problem with all this "grant 
>> mutability/immutability", which
>> is that we're just degenerating into C++ with its const_cast. With it, 
>> the
>> compiler has few, if any, guarantees about the constness of anything 
>> --- it can
>> always be casted away.
> 
> Casting away mutability (unless I'm totally nuts) is always safe. 
> Casting away immutability should never be allowed.

Exactly.  This is much of the reason for the "const as default" idea, as 
it makes sense to convert something to a more general representation (in 
this case mutable to immutable) but not vice-versa.  C++ got this 
backwards by making mutable the general category.


Sean



More information about the Digitalmars-d mailing list