const

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sun Apr 27 15:46:26 PDT 2008


Janice Caron wrote:
> On 27/04/2008, Bruno Medeiros <brunodomedeiros+spam at com.gmail> wrote:
>>  It's impossible? How about:
>>   const int x = someFuncThatReturnsConst();
> 
> x is still immutable.
> 
> 

Well... in this case yes, but only because it is a basic type. Your 
assertion still does not hold: "it is /impossible/ to declare a const 
variable that isn't, in fact, invariant".
Like I said just before, the example should have a type other than a 
basic type:

   const int* x = someFuncThatReturnsConst();

x is const, not invariant. (altough it does happen that the *head-value* 
of x is indeed conceptually invariant, because it was copied and is unique)



-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list