Proposal: Exceptions and @nogc

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 2 08:24:12 PDT 2017


On 4/2/17 9:14 AM, Walter Bright wrote:
> On 4/1/2017 11:50 PM, Nicholas Wilson wrote:
>> On Sunday, 2 April 2017 at 05:16:23 UTC, Walter Bright wrote:
>>> Problem
>>> =======
>>>
>>> [...]
>>
>> How will this interact with preallocated exceptions (e.g.  from
>> Liran's dconf
>> talk last year)?
>
> It will copy them and throw the copy.

Copy means allocate and then deallocate in the catch, defeating the 
whole propose of preallocating. Would it be possible to just set a bit 
somewhere that indicates that the exception is preallocated and need not 
be freed.

So for instance:

throw new Exception; // this is allocated exception

auto e = makeMeAnException();
throw e; // this is preallocated exception (need not be freed in the catch)

---
Dmitry Olshansky


More information about the Digitalmars-d mailing list