Memory allocation purity

Meta via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 18:40:30 PDT 2014


On Thursday, 15 May 2014 at 01:33:36 UTC, Idan Arye wrote:
> On Wednesday, 14 May 2014 at 22:50:10 UTC, w0rp wrote:
>> I think even C malloc should be considered pure. True, it 
>> affects global state by allocating memory, but it never 
>> changes existing values, it just allows for new values. free 
>> is pure because it isn't side-effecting, it deallocates what 
>> you give it. That's just my perspective on it though, others 
>> might have other views on it.
>
> `free` is not pure, because if you have a reference to that 
> memory that reference is no longer valid.

It is weakly pure, i.e., it can only affect the world through the 
parameters given to it (and the state of the computer's memory... 
but we should ignore that).


More information about the Digitalmars-d mailing list