Const by Default

renoX renosky at free.fr
Thu Jun 28 12:25:44 PDT 2007


Reiner Pope a écrit :
> David B. Held Wrote:
>> So if you look at many other areas where 'implicit X' has been
>> tried, you see a lot of examples of bad features, some of which
>> were actually removed.  Let's think very carefully and critically
>> before we assume 'implicit in' is not one of them...it's only one
>> char away from 'implicit int'. ;>
> But what's to stop someone turning your argument completely around?
> *Without* CbD, you can modify the variables even without asking for
> it: the variable types are implicitly mutable. But *with* CbD, you
> have to explicitly say, "I want this to be mutable." Doesn't this
> make it more explicit: a good thing?

Well, if this was always true, this would be a good thing, unfortunately 
this isn't true when there is some aliasing between a mutable parameter 
and a const parameter..

Sure, aliasing doesn't occur often in real life, but it's still a 
possibility that you have to take into account in your code..

[And no I don't have a simple solution]

renoX
> 
> I agree that things like using 'ref' or 'final' don't entirely make
> sense to 'turn const off.' But I don't see this problem with a
> 'mutable' annotation, instead.
> 
> Reiner



More information about the Digitalmars-d mailing list