On 27/04/12 19:08, Steven Schveighoffer wrote:
weak purity, I think, is one of the most revolutionary ideas to come from D.
Essentially, we get compiler-checked pure functions that can be written
imperatively instead of functionally.

I do agree with that; it's a very attractive aspect of D that a function or object can be internally imperative but pure as far as the outside world is concerned. Seeing that documented in Andrei's writings was another "Wow!" moment for me about D. :-)

What concerned me here was that the way my reputation() function was set up actually did change the public state of the object, which to my mind isn't even weakly pure. But I just wrote a fix which, contrary to my fears, didn't affect the speed of the program.

If the function is weakly pure, then it cannot be optimized based on purity, so
I don't think there is any way marking it pure *hurts*.

I was more concerned that the compiler wasn't identifying what to me was a violation of purity. I'm fairly sure I can also find a way to make some of those "nothrow" functions throw an error ...

Reply via email to