Memory allocation purity

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 23:58:50 PDT 2014


On Thu, 15 May 2014 05:51:14 +0000
via Digitalmars-d <digitalmars-d at 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


More information about the Digitalmars-d mailing list