GC.malloc is pure - wat

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 10:04:03 PDT 2015


On 4/24/15 11:43 AM, anonymous wrote:
> On Friday, 24 April 2015 at 15:21:43 UTC, Steven Schveighoffer wrote:
>> This is OK as long as f is *strong* pure. D pure is not the same as
>> the traditional definition.
>>
>> And GC.malloc is not strong pure, as it returns mutable data.
>
> Ah, this is the piece I was missing. I was aware of weak/strong pure,
> but I didn't know the return type plays a role in that.
>
> Could core.stdc.stdlib.malloc and friends also be marked pure then?

IMO, yes. But not everyone agrees with that.

Definitely, free has issues with being pure. And if free cannot be pure, 
there's not much point in making malloc pure. But I could see something 
like RefCounted that uses malloc being pure.

-Steve


More information about the Digitalmars-d mailing list