www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1207] New: Documentation on destructors is confusing

reply d-bugmail puremagic.com writes:
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.


-- 
May 01 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1207


bugzilla digitalmars.com changed:

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





Fixed DMD 1.018 and DMD 2.002


-- 
Jul 01 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1207


wbaxter gmail.com changed:

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





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.


-- 
Jul 01 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1207


bugzilla digitalmars.com changed:

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





Fixed dmd 1.032 and 2.016


-- 
Jul 09 2008