GC.malloc is pure - wat

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 11:48:43 PDT 2015


On 4/24/15 1:57 PM, deadalnix wrote:
> On Friday, 24 April 2015 at 17:45:57 UTC, anonymous wrote:
>> 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.
>
> GC.free should probably not be pure, but that is also not at all what
> you talk about in previous posts, which led me to think you are
> essentially doing a stunt as to not admit you were wrong.

I think you are thinking of @safe-ty. malloc and free can be pure, but 
must be contained properly.

purity when it comes to mutable data is a tricky thing.

-Steve


More information about the Digitalmars-d mailing list