On 18/12/2010 08:52, spir wrote:
On Fri, 17 Dec 2010 02:42:14 -0500
bearophile<[email protected]>  wrote:

http://www.reddit.com/r/programming/comments/enajl/purity_in_d_language/

Bye,
bearophile

I take the opportunity to question the def of weakly pure.

-1- How can this even compile?
        pure append (ref int[] a, int i) {a ~= i;}
The _only_ task of this func is to change state.


It is best not to think of D's pure as saying the function is pure in the traditional sense (side-effect free), but rather to say the side-effects are confined to the function's parameters only (and the state/data that is transitively reachable from them).

The key benefit of this is that it allows the *caller* of such pure function to determine which subset of state/data *may* change by a call to such function.



--
Bruno Medeiros - Software Engineer

Reply via email to