Memory allocation purity

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Thu May 15 07:34:59 PDT 2014


On Thursday, 15 May 2014 at 13:40:16 UTC, Manu via Digitalmars-d 
wrote:
> Why should returning a mutable pointer imply weak purity?

The argument here is that a valid mutable pointer returned from a 
pure function could always point to a new allocation, as new is 
allowed in pure code.

More precisely, the only way to return a valid mutable pointer 
from a parameterless function is to make it point to a new 
allocation, so allowing memory allocations does not even preclude 
the inference of stronger guarantees here.

David


More information about the Digitalmars-d mailing list