forcing "@nogc" on class destructors

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 20 16:37:53 PST 2015


On Wed, 21 Jan 2015 00:29:21 +0000
Kapps via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On Tuesday, 20 January 2015 at 18:12:27 UTC, ketmar via 
> Digitalmars-d wrote:
> > let's see how this proposal will be rejected. will there be 
> > some sane
> > reasons, or only the good old song about "broken code"? make 
> > your bets!
> 
> Lots of functions can theoretically allocate, but don't in the 
> way you call them. For example, a function that checks for 
> invalid arguments and throws an exception if any are passed in. 
> It can't be @nogc because it throws, but it's perfectly valid to 
> call in a constructor.
nothing is valid with calling even potentially allocating function in
dtor.

> Also, what about classes allocated with malloc/emplace that are 
> then destroyed/freed?
that's easy: mark that destructors with proposed `@gc` attribute. this
way you will explicitly tell the compiler that you know what you're
doing here and taking all responsibility for your actions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150121/650a654d/attachment-0001.sig>


More information about the Digitalmars-d mailing list