purity question

Seb via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 29 06:17:39 PDT 2017


On Monday, 29 May 2017 at 08:49:07 UTC, ketmar wrote:
> Brad Roberts wrote:
>
>> libraries that themselves aren't marked pure, there's a real 
>> need for escape hatches.  A simple example: anything that has 
>> a malloc/free pair.
>
> they aren't pure. it is a sad misconception about purity, which 
> D makes even more complex by allowing to mark, for example, 
> *setters* as pure. but still, `malloc()` and `free()` aren't 
> pure. and while various functions in std.math, for example, are 
> marked `pure`, they aren't too.

There is pureMalloc since 2.074.0 (it was never announced):

https://github.com/dlang/druntime/pull/1746

However, without a pureFree it's rather limited in usefulness and 
needs to be workaround in real life:

https://github.com/dlang/druntime/pull/1718


More information about the Digitalmars-d-learn mailing list