On 9 April 2013 14:39, Walter Bright <newshound2@digitalmars.com> wrote:
On 4/8/2013 5:37 AM, Manu wrote:
    Only builtins are pure in the sense of 'C'.  Even functions considered
    PUREstrong by the frontend may update an internal state, so the rules just
    don't apply.  Except for maybe global functions...   In any case, the only
    benefit you can reap from 'D pure' functions are that they are more likely
    to be const-folded / inlined.

Oh my god... ..... this is the most upsetting thing I've heard all day! :(
No really, I have been SOOOO excited for so long about this optimisation
potential in D!
There's gotta be something that can be done! >_<

I believe Iain is incorrect. Pure functions cannot squirrel away any persistent state.

Are you saying the example above is not actually valid code?

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

That's not pure. Call it twice with the same args, you'll different answers. How can that possibly be considered pure in any sense?
And it's useless in terms of optimisation, so why bother at all? What does it offer?