Discussion Thread: DIP 1042--ProtoObject--Community Review Round 1
Timon Gehr
timon.gehr at gmx.ch
Sat Jan 15 11:04:23 UTC 2022
On 15.01.22 11:22, Elronnd wrote:
> On Saturday, 15 January 2022 at 10:17:39 UTC, Timon Gehr wrote:
>> Seems like that would make class object construction impure.
>
> Meh paper over it with implementation-specific hacks.
You can't, as any `pure` function can just call toHash.
> No one complains about pureMalloc.
Not true, but that problem is a bit more nuanced and I think it can be
fixed.
https://dlang.org/library/core/memory/pure_malloc.html
```
UNIX 98 requires that errno be set to ENOMEM upon failure. Purity is
achieved by saving and restoring the value of errno, thus behaving as if
it were never changed.
```
Of course, never mind that it will return `null` upon failure. Some sort
of special casing of out-of-memory conditions seems inevitable (by the
GC, it's treated as an unrecoverable error, probably pureMalloc should
throw an OutOfMemoryError too in this case).
> (Well, arguably people _should_ be complaining about
> pureFree--pureMalloc is fine though--but.)
At least pureFree is not @safe. Of course, there is the whole issue that
its signature looks exactly like something that can often just be
optimized away. x)
More information about the Digitalmars-d
mailing list