On Wednesday, 28 May 2014 at 21:09:26 UTC, bearophile wrote:
Dicebot:
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`.
One wrapper should have a template argument to specify the type
of the items, to avoid the need of a cast. And instead of
throwing an error it could also return a Nullable (the sizeof
of such Nullable is the same as a pointer).
Nullable!(Titem*, null) talloc(Titem)(in size_t nItems);
Bye,
bearophile
I don't think wrapper with Nullable can be pure as it will
possibly return two different object values (and not just
different pointers) when called with same argument list. Throwing
an Error is crucial here.