On 2013-04-08 20:14, Simen Kjaeraas wrote:

Like others have stated, it's so you can do this:

struct Foo {
    int a = 0;
    pure int bar( int n ) { // Weakly pure
        a += n;
        return a;
    }
}

pure int Baz( int n ) { // Strongly pure
     Foo foo;
     return foo.bar( n );
}

Foo.bar has only local mutability, so if the Foo originated in a
(strongly) pure function, Foo.bar can be called inside that pure
function without violating the purity requirement.

The three levels (weakly pure/strongly pure/impure) are needed,
but a redesign would perhaps use a different keyword for weakly
pure.

I see.

--
/Jacob Carlborg

Reply via email to