On Wed, 23 Feb 2011 14:28:01 -0500, %u <wfunct...@hotmail.com> wrote:

No. pure is what we want. Changing it would break code and contradict TDPL (though the
addition of weakly pure isn't in TDPL). Strongly pure functions are essentially what you'd expect from pure. Weakly pure functions aren't, but they're necessary to make pure very useful, and there's no real benefit in using a new keyword or attribute to mark them. pure is the word used because we're modeling the idea that multiple calls to the same function with the same parameters have the same result - which is indeed the case with strongly pure functions. The funny case is weakly pure, but it's _not_ optimized out, and it's necessary for pure to be useful. You can clearly see whether a function is weakly or strongly pure by
looking at its signature, so I really don't think that it's an issue.

You keep on mentioning that weakly pure "is necessary for pure to be useful", but the problem is, even if something looks like a duck and walks like a duck, that doesn't mean it's a duck! Just because __declspec(noalias) _appears_ to mean the same thing as pure from the outside perspective that doesn't bother to peek too much into things doesn't mean that it's the same
thing (it obviously isn't).

Jonathan's point is that pure is what we say it is, because that's the definition of the language. If you want Microsoft's version of pure, use Microsoft's language/compiler. D's definition of pure is what we said it is.

Note that weak pure does fit within the definition of "having no side effects." That is, it cannot alter things it is not passed via parameters.

You're mentioning yourself that "weakly pure" isn't in the language specs... and if DMD is supposed to be a D compiler, shouldn't it actually follow the exact spec? (If "weakly pure" was actually intentional, then shouldn't it actually _be_ in the spec? Otherwise, the compiler
is clearly contradicting TDPL about a fundamental CS concept, isn't it?)

Strong pure and weak pure functions have no visible difference, and one can be used wherever the other is used. The difference between strong and weak pure is only how the compiler deals with them. So from a user perspective, strong and weak pure are the same, both are pure functions and have the same restrictions.

-Steve

Reply via email to