Thread overview
[Issue 1207] New: Documentation on destructors is confusing
May 01, 2007
d-bugmail
Jul 01, 2007
d-bugmail
Jul 01, 2007
d-bugmail
Jul 10, 2008
d-bugmail
May 01, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1207

           Summary: Documentation on destructors is confusing
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: wbaxter@gmail.com


The documentation under class.html#destructors states:
"""
When the garbage collector calls a destructor for an object of a class that has
members that are references to garbage collected objects, those references are
no longer valid. This means that destructors cannot reference sub objects. This
rule does not apply to auto objects or objects deleted with the
DeleteExpression.
"""

This is unclear.  Which "objects" does the last line refer to?  Does it mean sub-objects?    Does it mean that calling delete on a sub-object in your destructor is ok?  If it's really saying that it's a bad idea to *ever* refer to a pointer sub-object in *any* way in a destructor, then I think that fact should be stated much more clearly in big bold font.  Particularly it should be crystical clear on whether it's ok to call delete on your sub-objects, since this is what all C++ programmers do by reflex in their destructors.


-- 

July 01, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1207


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla@digitalmars.com  2007-07-01 14:00 -------
Fixed DMD 1.018 and DMD 2.002


-- 

July 01, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1207


wbaxter@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #2 from wbaxter@gmail.com  2007-07-01 14:23 -------
It's better, but now there's a little typo:
"""
This is because that the garbage collector ...
"""

Also the explanation seems to be a little out of order now.

It says this:
"""
The garbage collector is not guaranteed to run the destructor for all
unreferenced objects. Furthermore, the order in which the garbage collector
calls destructors for unreference objects is not specified.
"""

*after* having already said in the previous paragraph: "the garbage collector does not collect objects in any guaranteed order".  I think the above paragraph should be moved before the paragraph that explains why you can't reference sub-objects.


-- 

July 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1207


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED




------- Comment #3 from bugzilla@digitalmars.com  2008-07-09 22:39 -------
Fixed dmd 1.032 and 2.016


--