DMD 1.025 and 2.009 releases
Daniel919
Daniel919 at web.de
Tue Jan 1 16:07:57 PST 2008
>> C cx;
>> if (someCondition)
>> cx = new C(1);
>> else
>> cx = new C(2);
>> const(C) c = cx;
Wouldn't it be good if there was a way to express
"I will not modify this anymore", instead of creating a new object?
C c;
if (someCondition)
c = new C(1);
else
c = new C(2);
cast(invariant) c; //from now on, c will not change anymore
//more code ...
The last line could do sth like:
{ //new scope
invariant c = cast(invariant) c; //shadowing declaration
//more code ...
} //ends just before the ...
} //... end of the outer scope
Best regards,
Daniel
More information about the Digitalmars-d-announce
mailing list