Proposal 2: Exceptions and @nogc
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Apr 10 17:11:01 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.
Actually, in addition to user defined overloads (which are
deprecated, granted), `new` also can mean stack allocation
already! See the `scope` storage class and scope classes.
The language is free to optimize `new` as it sees fit. (IMO,
that's the only real justification for it even being a built in
language feature instead of an ordinary library function.) The
real changes in this proposal are:
1) if the compiler is aware that new will be implemented in such
a manner as to not use the gc, it will pass the static @nogc fit.
2) the catch block is restricted a bit in order to enable this
optimization.
`new` itself isn't really changing since it was already allowed
to do this in cases the compiler can prove its lifetime.
More information about the Digitalmars-d
mailing list