Extended Type Design - existing keywords

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Fri Mar 16 15:44:30 PDT 2007


Frits van Bommel wrote:
> kris wrote:
>> How about this? Using existing keywords, with a rename of "const":
>>
>> 1) final       - rebinding of a value to a name
> [moved '2)']
>> 3) constant    - a value that never changes
> 
> These two are fine by me.
> 
>  > 2) invariant   - a read-only view of a data structure
> 
> No. Just No.
> For one thing, the data structure can vary :) : anyone with a mutable 
> reference can change the value from under your nose, so "does not vary" 
> simply isn't applicable here.
> But more importantly, invariant has a very clear and defined meaning in 
> computer science. It should not be overloaded like this.

Much of the terminological problem is that it's hard to express const's 
imprecision (as opposed to super const's precision) tersely.

One of my ideas was using "const" for truly set in stone, and using 
"const?" to mean that the object may or may not have originated as 
const. But code with question marks everywhere would look odd.


Andrei



More information about the Digitalmars-d mailing list