http://d.puremagic.com/issues/show_bug.cgi?id=8139

           Summary: Make objects really disposable by addition of "Object
                    finalized" assertion
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: contracts, diagnostic
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: verylonglogin....@gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin....@gmail.com> 2012-05-24 
14:39:44 MSD ---
Original NG thread:
True disposable objects (add "Finalized!" assertion)
http://forum.dlang.org/thread/jo0p3a$aue$1...@digitalmars.com

First message from NG thread:
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.

Isn't it no-brainer? Isn't it the only way to debug manual memory 
management and shared resources without error-prone boilerplate?

This is what I missed in C#, where I can dispose an object but I have to 
manually check the object isn't disposed every time I use it or in every 
it's method to find where I'm doing something with a disposed object by 
a mistake.


IMHO finding using of dead references is almost as major as not allowing 
to free memory of alive objects (I mean GC), but GC is often implemented 
and dead references detection isn't.

Strongly require your thoughts.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to