Steven Schveighoffer wrote:
On Fri, 17 Dec 2010 02:42:14 -0500, bearophile
<bearophileh...@lycos.com> wrote:
http://www.reddit.com/r/programming/comments/enajl/purity_in_d_language/
Bye,
bearophile
You've got two statements here which are both sort-of true, but taken
together are not correct:
<1>
Another inaccuracy (really an omission) is that a weakly pure function
is just like a pure function but cannot be memoized. In fact, it cannot
be optimized in any way like strongly pure functions can.
<2>
This actually ties together nicely with my first point -- a pure
function that returns a mutable pointer must be weakly pure.
A function which has immutably pure parameters can undergo *some*
optimisation, even if the return value is a mutable pointer.
For example, if the parameters are identical for both calls, you can do
a deepdup of the first return value instead of calling the function again.