Fully transitive const is not necessary

guslay guslay at gmail.com
Thu Apr 3 11:20:19 PDT 2008


Walter Bright Wrote:

> 
> Logical const just utterly breaks the whole system. 


I think we had a different expectations about invariant and pure.

Do you believe that (A),

   invariant A a;
   int x = f_pure(a);
   g_not_pure(a); // potentially mutating mutable members of A
   int y = f_pure(a);
   int z = f_pure(a);

which is can be transformed without problem to (B),

   invariant A a;
   int x = f_pure(a);
   g_not_pure(a);
   int y = f_pure(a);
   int z = y;

MUST also be equivalent to (C) ?

   invariant A a;
   int x = f_pure(a);
   int y = x;
   int z = x;
   g_not_pure(a);


A = B = C is only possible if invariant A as no mutable part. I agree. Is this your position?

I was expecting a weaker pure model, where only A = B is true (optimization based on purity only possible inside a contiguous block of pure functions).

If this is correct then I understand your concerns against logical const.





More information about the Digitalmars-d mailing list