Subtyping and Subclasses

Stephan Diehl (diehl@cs.uni-sb.de)
Fri, 11 Apr 1997 16:33:44 +0200 (CEST)

In VRML++ the class hierarchy is used as the basis
for a type system. The type system helps to detect
possible run-time errors at compile-time (preprocessing).
Now, what are the requirements, that a class hierarchy
can be used in such a way.

1) A is a subtype of B <=> A has all properties of B

In VRML properties are events and fields. (There is also
another property, namely that certain nodes can only be
used at certain positions, e.g. only child nodes as the
values of the children field. But we hope, that these
restrictions verbally expressed in the VRML spec,
can be explicitly defined with the help of the type system)

2) A is a subclass of B => A is a subtype of B

But in general the reversed implication (<=) does
not hold. 2) says that subclassing guarantees
subtyping.

>From 1) and 2) we infer that inheritance must
preserve interfaces (properties). A subclass
must provide all fields and events of its
superclass. For multiple inheritance we get
into trouble, more than one superclass can
have for example event e. So do we inherit
e from the first or the second superclass.
This question comes from a programming language
point of few. If we consider it from the
VRML perspective, we might come to the conclusion
that inherits both events (or Eventhandler in OOVRML).
This is possible, because we can route the input
event e of the new class to the input events e
of its superclasses.

I think the problem we have with inheritance is,
that we would like to use it to compose graphical
objects. But inheritance is to weak for this.
Sungwoo's approach to put the superclasses
into the children field of the subclass
seems to be the outmost we can achieve. But
it would restrict inheritance to Transform
nodes.

BTW on the homepage of our WG you can find
a list of topics to discuss and a mail archive.

Cheers
--Stephan