@nogc exceptions?

Petar Petar
Sun May 19 06:09:41 UTC 2019


On Sunday, 19 May 2019 at 05:59:11 UTC, Manu wrote:
> On Sat, May 18, 2019 at 10:20 PM Nicholas Wilson via 
> Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>>
>> On Sunday, 19 May 2019 at 05:05:32 UTC, Manu wrote:
>> > Okay...How do I do it? I just get:
>> >   throw new Exception("ex");
>> >   > error : cannot use `new` in `@nogc` function
>>
>> pass -preview=dip1008 to the compiler
>
> Oh right. Is this a breaking change or something?

Yes, at minimum it changes the type checking of the `throw new 
<Ex>` expression (e.g. it's no longer not @nogc). It also makes 
such exceptions not garbage collected, but reference counted, so 
the user should not keep an exta reference around as the compiler 
and the runtime can't track that.
But most of all, such changes needs to be tested with a larger 
set of third-party libraries before we can consider tuning them 
on by default. Some projects have already started doing that, but 
we're still in the early stages.


More information about the Digitalmars-d mailing list