Why will the delete keyword be removed?

PercentEwe make at example.org
Thu Jul 15 08:02:17 PDT 2010


== Quote from Max Samukha (spambox at d-coding.com)'s article
> Not that I fiercely disagree but ideally I'd want it to be obliterated
> to an invalid but easily recognizable state. It might help to discover
> dangling pointer errors early. Otherwise, leaving a destroyed object in
> a perfectly valid state may make debugging more fun than it needs to be.

You could use:
class A
{
   int guard = 0xdeadbeef;
   this () { guard = 0; }
   invariant () { assert (guard == 0); }
}

Really annoying, though, and it makes more sense to set the guard in the
destructor. (A compiler option to do something like this automatically
would be nice.)


More information about the Digitalmars-d mailing list