<div dir="ltr">On 9 April 2013 21:30, tn <span dir="ltr"><<a href="mailto:no@email.com" target="_blank">no@email.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tuesday, 9 April 2013 at 08:33:53 UTC, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 9 April 2013 18:04, Dicebot <<a href="mailto:m.strashun@gmail.com" target="_blank">m.strashun@gmail.com</a>> wrote:<br>
<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tuesday, 9 April 2013 at 07:57:37 UTC, Manu wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Are you saying the example above is not actually valid code?<br>
<br>
struct Foo {<br>
int a = 0;<br>
pure int bar( int n ) { // Weakly pure<br>
a += n;<br>
return a;<br>
}<br>
}<br>
<br>
That's not pure. Call it twice with the same args, you'll different<br>
answers. How can that possibly be considered pure in any sense?<br>
And it's useless in terms of optimisation, so why bother at all? What does<br>
it offer?<br>
<br>
</blockquote>
<br>
It is valid code. It is "weak pure". "pure' keyword means both<br>
"strong pure" or "weak pure" depending on function body. Crap.<br>
<br>
</blockquote>
<br></div></div><div class="im">
How can 'weak pure' reasonably be called any kind of 'pure'? It's not pure<br>
at all. The function returns a completely different result when called<br>
twice.<br>
</div></blockquote>
<br>
The returned results are different because the parameters you are calling it with are different. Note that for member functions 'this' is also passed implicitly as a ref parameter. On the second call it has different value than on the first call. If you don't want to allow mutating 'this' you should make the function const, thus making the implicit 'this' parameter const ref.<br>
</blockquote></div><br></div><div class="gmail_extra" style>Ah, yes. Good point. I don't know how I missed that point prior!</div><div class="gmail_extra" style>Okay sir, I buy your argument! :)</div></div>