Memory allocation purity

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu May 15 09:03:00 PDT 2014


On 05/15/2014 05:24 PM, Andrei Alexandrescu wrote:
> On 5/15/14, 3:31 AM, luka8088 wrote:
>> Yeah, I read all about weak/string purity and I do understand the
>> background. I was talking about strong purity, maybe I should pointed
>> that out.
>>
>> So, to correct myself: As I understood strong purity implies
>> memoization. Am I correct?
>
> Yes, as long as you don't rely on distinguishing objects by address.
>
> Purity of allocation is frequently assumed by functional languages

Examples?

> because without it it would be difficult to get much work done.

Why?

> Then,
> most functional languages make it difficult or impossible to distinguish
> values by their address.

If it's not impossible because of lack of the concept it's not a pure 
functional language.

> In D that's easy. A D programmer needs to be
> aware of that, and I think that's fine.
>
>
> Andrei
>
>

It's not fine: The spec claims that this problem does not exist.

http://dlang.org/function.html

"... and in cases where the compiler can guarantee that a pure function 
cannot alter its arguments, it can enable full, functional purity (i.e. 
the guarantee that the function will always return the same result for 
the same arguments)"


More information about the Digitalmars-d mailing list