Why will the delete keyword be removed?

bearophile bearophileHUGS at lycos.com
Wed Jul 14 18:26:14 PDT 2010


Jonathan M Davis:
> With things being put in the pre-
> constructor state by clear(), it's not as obvious what's going on when things go 
> wrong. Ideally, you'd want things to blow up when such an object was used, with 
> it clearly indicating that it was because you used an object which isn't 
> supposed to exist anymore.

If you want the "failfast" (http://en.wikipedia.org/wiki/Failfast ) system, then you can use the last bit of the monitor or virtual table pointer to store store a boolean that denotes the cleared state of the object. This free space is not available for structs allocated on the heap, dynamic arrays, etc, and then you have to test this bit (in nonrelease mode only?) often, this slows down code a little.

Bye,
bearophile


More information about the Digitalmars-d mailing list