GC.malloc is pure - wat

anonymous via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 10:45:56 PDT 2015


On Friday, 24 April 2015 at 17:07:20 UTC, deadalnix wrote:
> On Friday, 24 April 2015 at 15:43:17 UTC, anonymous wrote:
[...]
>> Could core.stdc.stdlib.malloc and friends also be marked pure 
>> then?
>
> No.
>
> Allocating on the GC is "stateless" as the GC will handle the 
> state by itself, from the program perspective, there is no 
> state to maintain.
>
> malloc require free, and the state management is pushed on the 
> application rather than the runtime. It is not pure.

There's also GC.free, which is also marked pure.

I can't see how GC.malloc followed by GC.free is more pure than 
stdlib malloc followed by stdlib free.


More information about the Digitalmars-d mailing list