const by default.
Don Clugston
dac at nospam.com.au
Wed Jul 5 23:17:49 PDT 2006
Sean Kelly wrote:
> 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.
And then had to add the 'mutable' keyword anyway <g>.
More information about the Digitalmars-d
mailing list