Stick a fork in it

Don Clugston dac at nospam.com.au
Thu May 10 23:42:22 PDT 2007


Chris Nicholson-Sauls wrote:
> Sean Kelly wrote:
>> Bill Baxter wrote:
>>> renoX wrote:
>>>> Walter Bright a écrit :
>>>>> Chris Nicholson-Sauls wrote:
>>>>>> Actually, that'll be 'final'.  The new 'invariant' will mean "this 
>>>>>> *data* absolute does not change", and the new 'const' will mean 
>>>>>> "this is an *immutable view* into data owned by other code, which 
>>>>>> *may* change".  (If I'm remembering/understanding right.)
>>>>>
>>>>> You're right.
>>>>
>>>> If the keywords are really like this, it's a bit weird, IMHO the 
>>>> most interesting one is 'invariant' which happens to be also the one 
>>>> with the longest name..
>>>
>>> But invariant is also the one most likely to appear on a line all by 
>>> itself with just a single variable and a simple initializer.  And 
>>> most uses will be close to the left margin I suspect.  And even if 
>>> invariant is the most interesting, I think const will still be the 
>>> most used.
>>
>> I still can't keep all these straight in my head--the words are all 
>> synonyms.  Hopefully that will change after I've used them a bit.
>>
>>
>> Sean
> 
> I think I've just about gotten my head around it, but also feel it will 
> come moreso with use.  I think of the word invariant as a "stronger" 
> word than const(ant) -- the latter being a more common term, and the 
> former more... formal -- so that's how I deal with it; ie, that 
> 'invariant' is a "stronger contract" than 'const' is.  At least my time 
> with Java semi-prepared me for 'final'.
> 
> -- Chris Nicholson-Sauls

Mentally, I can cope with const if I view it as abbreviation of 
'constrained' (if you think of it as 'constant', IMHO it gets horribly 
nonintuitive). It's obvious that 'invariant' is an extreme case of 
'constrained'.



More information about the Digitalmars-d-announce mailing list