std.experimental.allocator.make should throw on out-of-memory
Alex Parrill via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 20 11:07:05 PDT 2016
On Wednesday, 20 April 2016 at 01:59:31 UTC, Vladimir Panteleev
wrote:
> On Tuesday, 19 April 2016 at 22:28:27 UTC, Alex Parrill wrote:
>> * It eliminates the incredibly tedious, annoying, and
>> easy-to-forget boilerplate after every allocation to check if
>> the allocation succeeded.
>
> FWIW, you can turn a false-ish (!value) function call result
> into an exception by sticking .enforce() at the end. Perhaps
> this is the use case for a Maybe type.
Yes, enforce helps (and I forgot it reruns its argument), but its
still boilerplate, and it throws a generic "enforcement failed"
exception instead of a more specific "out of memory" exception
unless you remember to specify your own exception or message.
More information about the Digitalmars-d
mailing list