On Wednesday, 28 May 2014 at 21:31:41 UTC, Nordlöw wrote:
It is also because `malloc` can return null when out of memory
and `new` will throw an Error. Wrapper around `malloc` that
throws `OutOfMemoryError` on null can be considered of same
purity class as `new`.
Does this mean that I should write and use such a wrapper for
malloc?
/Per
I don't know. I believe within current language semantics even
considering `new` pure is broken, there was a very recent thread
discussing it in digitalmars.D group.
If you can be sure that your code won't break basic sanity
requirements (never comparing allocated immutable pointer
identity, only pointed values) it should work fine. But I have
never done it in my code and not aware of possible pitfalls.