std.experimental.allocator.make should throw on out-of-memory

Alex Parrill via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 20 14:14:36 PDT 2016


On Wednesday, 20 April 2016 at 19:18:58 UTC, Minas Mina wrote:
> On Tuesday, 19 April 2016 at 22:28:27 UTC, Alex Parrill wrote:
>> I'm proposing that std.experimental.allocator.make, as well as 
>> its friends, throw an exception when the allocator cannot 
>> satisfy a request instead of returning null.
>>
>> [...]
>
> I believe it was designed this way so that it can be used in 
> @nogc code, although I might be wrong.

This is IMO a separate issue: that you cannot easily throw an 
exception without allocating it on the GC heap, making it too 
painful to use in nogc code.

I've heard mentions of altering exception handling to store the 
exception in a static memory space instead of allocating them on 
the heap; I'd much rather see that implemented than the bandage 
solution of ignoring exception handling.


More information about the Digitalmars-d mailing list