Proposal 2: Exceptions and @nogc

via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 10 17:07:10 PDT 2017


On Monday, 10 April 2017 at 23:16:48 UTC, Meta wrote:
> My knee jerk reaction is that it's a very bad thing that "new" 
> means the same thing everywhere in the language (allocate and 
> initialize some GC-managed memory), except for this one case.

`new SomeClass` has never implied GC allocation only - see 
https://dlang.org/spec/class.html#allocators, though I agree it 
looks kind of odd to add a special case. But it's hard to miss 
the benefits - all code that was not @nogc only because of 
allocating new exceptions and throwing them, becomes @nogc for 
free. And this is huge - just grep for uses of enforce in Phobos 
and many other prominent projects.


More information about the Digitalmars-d mailing list