I just got it! (invariant/const)
Steven Schveighoffer
schveiguy at yahoo.com
Wed Apr 9 12:15:11 PDT 2008
"Janice Caron" wrote
> On 09/04/2008, Steven Schveighoffer wrote:
>> class C
>> {
>> int *m;
>> invariant(int *) i;
>> }
>>
>> pure int getI(C c)
>> {
>> return *i;
>> }
>>
>> There may be a reason to use i, but not m in a pure function. Why
>> should
>> pure restrict this? It's technically correct and statically verifiable.
>
> Except that there's no way to initialise i.
>
> My understanding of the whole raw vs cooked thing in
> accu-functional.pdf is that it's a way of making an entirely invariant
> class. There would still be no way to create a class with some members
> invariant and others not, except for those that can be initialised at
> compile time.
I think this is a limitation that should be lifted, as there may be reasons
to have an invariant member of a class that is set upon construction. I
can't see any reason to disallow it.
-Steve
More information about the Digitalmars-d
mailing list