any news on const/invariant?

Oskar Linde oskar.lindeREM at OVEgmail.com
Wed Nov 28 02:48:03 PST 2007


Walter Bright wrote:
> Janice Caron wrote:
>> If we ditch
>> const-as-an-attribute altogether, it would require only minor changes
>> to get code compiling again: e.g.
>>
>>     const int[] table = [ 1, 2, 3, 4 ];
>>
>> becomes
>>
>>     const(int[]) table = [ 1, 2, 3, 4 ];
> 
> I think it would be pretty hard to give up:
> 
>     const x = 3;
> 
> Also, C++ has const as both a storage class and a type constructor, and 
> yes, they have subtly different meanings. This doesn't seem to cause any 
> major problems.

Shouldn't const as a storage class mean really constant, so that 
typeof(&x) above would be invariant(int)* instead of const(int)*?
And in that case, wouldn't it be more logical if the keword "const", as 
a type modifier meant constant (what invariant is today), and another 
keyword was used for the weaker access protection... Say "readonly".

*ducks*

;)


-- 
Oskar



More information about the Digitalmars-d mailing list