> ...
> So does it in fact extend itself or should it say "Every OTHER class
> has Object as a superclass?
> ...
>> ...
>> So does it in fact extend itself or should it say "Every OTHER class
[quoted text clipped - 3 lines]
> I would think that having a class extend itself doesn't make
> a lot of sense, and would involve some serious problems.
Back in CS101, I seem to recall being taught that the parent node of any
tree was the node itself. I guess if Object doesn't extend Object, then
the Java class hierarchy isn't really a tree...
> First of all, the cyclic inheritance restriction comes into play
> and forbids this.
>
> If that were somehow overridden, then there would be an
> infinite regress in any method that invoked super().
No, just methods that don't check for the terminal case of Object. Even
without Object extending Object, the regression has to check for a base
case. The regression or while-loop that invokes super() has to know
when to end, anyway.
> Then there's the problem of duplication of data. If field X
> is defined in Object, is it also defined in the parent of Object?
> And in the parent of the parent, etc.?
Object doesn't have any public fields, so I'm not sure that's an issue.
> All of the above really reduce to one objection, not three,
> but they illustrate the multiple facets of the contradiction
> involved in self-inheritance.
Ruby has a single root Object class, and its superclass() method returns
the equivalent of null. I wonder how Python handles this.
Oliver Wong - 07 Jul 2006 21:33 GMT
> Back in CS101, I seem to recall being taught that the parent node of any
> tree was the node itself. I guess if Object doesn't extend Object, then
> the Java class hierarchy isn't really a tree...
I think, for convenience in writting recursive code, it's useful to
treat any node within a tree as a tree as well. But when we need the
precision (such as now), I think it's useful to distinguish between the tree
and the nodes that make up the tree. If a tree has a parent, that parent
would be a forest, not a tree, nor a node.
In most contexts, a tree is nothing more than a connected acyclic graph.
Under this definition, the Java class hierarchy is a tree; if you include
interfaces, it is no longer a tree. Taken literally, if any node is
connected to itself, that's a cycle, and thus not a tree.
- Oliver
Jeffrey Schwab - 07 Jul 2006 22:34 GMT
>> Back in CS101, I seem to recall being taught that the parent node of
>> any tree was the node itself. I guess if Object doesn't extend
[quoted text clipped - 10 lines]
> include interfaces, it is no longer a tree. Taken literally, if any node
> is connected to itself, that's a cycle, and thus not a tree.
Excellent point. :)
Jochen Schulz - 09 Jul 2006 17:17 GMT
* Jeffrey Schwab:
> Ruby has a single root Object class, and its superclass() method returns
> the equivalent of null. I wonder how Python handles this.
Python's class <type 'object'> has no bases either:
>>> object
<type 'object'>
>>> object.__bases__
()
(object.__bases__ is an empty list since Python allows multiple
inheritance but object doesn't have a base.)
But the root of Python's inheritance hierarchy is quite interesting.
Since classes are objects, too, <type 'object'> is an instance of <type
'type'>, the mother of all types. At the same time, <type 'type'> is an
instance if itself and derives from <type 'object'>. %-)
Good resource: <http://www.cafepy.com/article/python_types_and_objects/>
J.

Signature
Thy lyrics in pop songs seem to describe my life uncannily accurately.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>