True disposable objects (add "Finalized!" assertion)

Sean Kelly sean at invisibleduck.org
Fri May 4 11:55:58 PDT 2012


On May 4, 2012, at 7:28 AM, Denis Shelomovskij wrote:

> This idea is too obvious and I suppose I'm the only one not knowing it, but I have never seen it's implementation. Why?
> 
> The idea:
> 1. `Object` class has hidden `isAlive` field which is true since construction and up to finalization.
> 2. Every method asserts that the object is alive first.
> 3. There is an `finalize` function that just rt_finalize an object in debug mode but can even free memory in release mode.

rt_finalize currently nulls out the vtbl pointer, which can server as an isAlive flag if desired.


More information about the Digitalmars-d mailing list