Don napisał: > You're operating with a different definition. There are actually three > levels. For extra clarity, let's split strongly-pure into two: > > immutably pure == all parameters are immutable > const pure == all parameters are const > weakly pure == no access to globals > > The interestingly thing is that an immutably pure function can safely > call a weakly-pure function. The only things the weakly pure function > will be able to change, are variables which are local to the immutably > pure functions. > > The only difference between weakly pure and immutably pure is the > guarantees which are made about the parameters. And this is already > covered by the const modifiers in the function signature. So that > concept doesn't actually need to be part of pure.
Good stuff. Separating restriction on globals and on parameters opens the door for compiler-enforced guarantees on a much wider range of cases. > Note that this is possible only because immutable and const are > transitive. It wouldn't be possible with head-const, or logical const. But it would be possible with tail const. Quite a few functions could be made immutably pure if it meant tail immutability of their parameters. One example are manipulations of ranges on immutable structures. > Transitive const gives us an absolutely huge win. I can't agree more. -- Tomek