Memory allocation purity
w0rp via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 14 15:50:09 PDT 2014
On Wednesday, 14 May 2014 at 22:42:47 UTC, Brian Schott wrote:
> What is the plan for the "pure"-ity of memory management?
>
> Right now the "new" operator is considered to be pure even
> though it is not, but related functinos like malloc,
> GC.addRange, GC.removeRange, and others are not.
>
> This prevents large portions of std.allocator from being pure.
> This then prevents any containers library built on
> std.allocator from being pure, which does the same for any
> funcions and data structures written using those containers.
>
> If malloc can never be considered pure, even when hidden behind
> an allocator, why can it be considered pure when hidden behind
> the GC?
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.
More information about the Digitalmars-d
mailing list