On std-discussion, Shakti Misra asked:

I have seen in a lot of places code like

int i;

if(someConditionIstrue)

{

Do some operations and calculate the value of i;

i = some calculated value;

}

use i; //Note this value is only used not changed. It should not be changed.

But unfortunately in this case there is no way to guarantee it.

so now if some one comes and does

i = 10;// This is valid

What i was thinking: is there a way to tell that "i" can be set only once?

After that it will be a constant. Something like

const once int i;

if(someConditionIstrue)

{

Do some operations and calculate the value of i;

i = calculated value;

}

use i; //Note this value is only used not changed.

i = 10;// Compiler error