const by default.

BCS BCS at pathlink.com
Fri Jul 7 13:30:19 PDT 2006


Walter Bright wrote:
> BCS wrote:
> 
>> What I want is a way to get an assurance by the compiler that a 
>> referenced value will not be changed. This would require that const 
>> references (or a non mutable ones) can never be made into a mutable 
>> references.
>>
>> If I'm missing something, please point it out.
> 
> 
> You haven't missed something. The 'in' thing proposed above is not an 
> airtight guarantee, you could call it more of a 'sieve'. It's more of a 
> documentation aid. The compiler checking would be minimal and easily 
> subverted.

Uh... Uh... Please tell me that's not going to be the Final Solution?

A strong consistent const concept (IMVHO) would be a great thing for D. 
While the suggested use of "in" might help /some/, I don't see it being 
nearly as useful.

For one thing (and this is just a gut reaction) it don't seem vary 
extensible. I fear it might be just good enough that it won't ever get 
replaced with something better. Frankly, because of that, I'd rather see 
it left as-is or go to a highly restrictive const system than havening 
the "in" system be the primary const concept.



More information about the Digitalmars-d mailing list