www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 177] New: remove inheritance protection

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=177

           Summary: remove inheritance protection
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


Every class in D is inherit from the class 'Object'. D does not support
multiple inheritance. But if I do this:

class D{
}
class T : private D {
}

Now this invariant is not true any more.
The functionality from Object is no more visible to a user of T.
e.g. container can complain, they cannot access opEqual. 

I think the D spec is not logic in this point and the inheritance protection
should be removed.


-- 
Jun 06 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=177


bugzilla digitalmars.com changed:

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




------- Comment #1 from bugzilla digitalmars.com  2006-06-09 03:50 -------
If one needs to access members of the base class, it shouldn't be marked as
private. The compiler behaves as designed to for private base classes.


-- 
Jun 09 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=177


benoit tionex.de changed:

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




------- Comment #2 from benoit tionex.de  2006-06-09 04:57 -------
Is this a misunderstanding?

From the D-spec, section classes, first paragraph:
"The object-oriented features of D all come from classes. The class hierarchy
has as its root the class Object. Object defines a minimum level of
functionality that each derived class has, and a default implementation for
that functionality."

Now, if one inherits protected or private from any class, the class 'Object' is
no more visible. Thats my point. The compiler does it job right, but the spec
is not logic in this point.

The second argument for removing this protection is that this doesn't make
sense in a language without multiple inheritance. E.g. java does not have this
protected. I think exactly because of this.

Private inheritance is good for a "implemented with" relation. This makes sense
in C++, not in D. In D, a possible way is using mixins. (if bug 106 is fixed ;)
)


-- 
Jun 09 2006