<div dir="ltr">On 9 April 2013 14:39, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 4/8/2013 5:37 AM, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
    Only builtins are pure in the sense of 'C'.  Even functions considered<br>
    PUREstrong by the frontend may update an internal state, so the rules just<br>
    don't apply.  Except for maybe global functions...   In any case, the only<br>
    benefit you can reap from 'D pure' functions are that they are more likely<br>
    to be const-folded / inlined.<br>
<br></div><div class="im">
Oh my god... ..... this is the most upsetting thing I've heard all day! :(<br>
No really, I have been SOOOO excited for so long about this optimisation<br>
potential in D!<br>
There's gotta be something that can be done! >_<<br>
</div></blockquote>
<br>
I believe Iain is incorrect. Pure functions cannot squirrel away any persistent state.<br>
</blockquote></div><br></div><div class="gmail_extra" style>Are you saying the example above is not actually valid code?</div><div class="gmail_extra" style><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">
<br></div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">struct Foo {</div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">    int a = 0;<br></div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">
    pure int bar( int n ) { // Weakly pure<br>        a += n;<br>        return a;<br>    }<br>}</div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px"><br></div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">
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?</div><div class="im" style="font-family:arial,sans-serif;font-size:13.333333969116211px">
And it's useless in terms of optimisation, so why bother at all? What does it offer?</div></div></div>