If you could make any changes to D, what would they look like?

Patrick Schluter Patrick.Schluter at bbox.fr
Fri Oct 29 15:51:05 UTC 2021

On Thursday, 28 October 2021 at 22:48:10 UTC, Dukc wrote:
> On Thursday, 28 October 2021 at 19:46:32 UTC, Patrick Schluter 
> wrote:
>> Not at all. free cannot, by its semantic, be pure (same for 
>> malloc). Trying to make free pure is a silly challenge.
> https://dlang.org/phobos/core_memory.html#.pureFree

I don't understand it. It does not make any sense. pure functions 
are function that do not depend on global state for their result. 
Weak purity allows for some exception like for a print function 
which has global effects but these effects have no feedback and 
can ne ignored. This is not the case with allocation/free, which 
are, by defintion, dependend on a global state (even if only 
thread  local).
Each call to malloc, by definition must return another value 
and/or can return a same value with other parameter. The result 
does not depend on ANYTHING in its scope.
pure allocation/free is a recipe for disaster.
My understanding of purity at l east.

More information about the Digitalmars-d mailing list