On 15.5.2014. 8:58, Jonathan M Davis via Digitalmars-d wrote:
> On Thu, 15 May 2014 05:51:14 +0000
> via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> 
>> Yep, purity implies memoing.
> 
> No, it doesn't. _All_ that it means when a function is pure is that it cannot
> access global or static variables unless they can't be changed after being
> initialized (e.g. they're immutable, or they're const value types), and it
> can't call any other functions which aren't pure. It means _nothing_ else. And
> it _definitely_ has nothing to do with functional purity.
> 
> Now, combined with other information, you _can_ get functional purity out it -
> e.g. if all the parameters to a function are immutable, then it _is_
> functionally pure, and optimizations requiring functional purity can be done
> with that function. But by itself, pure means nothing of the sort.
> 
> So, no, purity does _not_ imply memoization.
> 
> - Jonathan M Davis
> 

Um. Yes it does. http://dlang.org/function.html#pure-functions
"functional purity (i.e. the guarantee that the function will always
return the same result for the same arguments)"

The fact that it should not be able to effect or be effected by the
global state is not a basis for purity, but rather a consequence.

Even other sources are consistent on this matter, and this is what
purity by definition is.

Reply via email to