On Tuesday, 9 April 2013 at 13:49:12 UTC, Dicebot wrote:
On Tuesday, 9 April 2013 at 12:56:04 UTC, Andrei Alexandrescu wrote:
It is valid code. It is "weak pure". "pure' keyword means both
"strong pure" or "weak pure" depending on function body. Crap.

s/body/signature/
s/Crap/Awesome/

Not gonna argue latter but former is just wrong.

struct Test
{
    int a;
    pure int foo1() // strong pure
    {
        return 42;
    }

    pure int foo2() // weak pure
    {
        return a++;
    }
}

Signature is the same for both functions.

Think of all your member functions as non-member functions taking the object as a ref parameter.

pure int foo1(ref Test this) {
    return 42;
}

shouldn't be strongly pure (as it can access mutable non local state).

Reply via email to