Inheritance (Is this the consensus??)

Stephan Diehl (diehl@cs.uni-sb.de)
Mon, 14 Apr 1997 12:42:46 +0200

The latest examples by Sungwoo have lead me to
the following proposal. What do you think, it's
strikingly easy. Could this be our consensus on
inheritance.

JJ mentioned
> the first node in a PROTO could be considered the base type.

and in accordance with this consideration
Sungwoo came up with a notion of inheritance which
I think we should develop further:

Sungwoo wrote:
> I've concluded that the idea of 'adding nodes in inheritance'
> is very poor.

and then he gives the following (still flawed) example
of a new inheritance notion:

CLASS Robot [...] {
Transform {
children [
A{}
B{}
]
}
}

CLASS Robot EXTENDS Transform [...] {
DEF SELF {
children [USE A, USE B]
}
DEF A ... # not directly added
DEF B ... # not directly added
}

I think, the second example is just a different way to
write the first. But the first example is how you
define a PROTO, it's just that the inheritance hierarchy,
that Robot is a subclass of Transform is not exploited
for a type system in VRML 2.0 and that the properties
(fields and events) of Transform are not automatically
added to those of Robot. *This latter point is very important !!!*
So we could drop the EXTENDS keyword,
replace PROTO by CLASS and allow interfaces
(IMPLEMENTS). An interface is defined like a PROTO,
but does not have a body:

INTERFACE Clock [ eventIn TimeSensor tick ].
INTERFACE Mover [ eventIn SFFloat move ].
INTERFACE Animator [ eventIn SFBoolean start ] EXTENDS Clock, Mover.
INTERFACE Talker [ eventIn SFString talk ].

CLASS MyRobot IMPLEMENTS Animator, Talker [ ... ]
{ Robot { ... }
...
}

What do you think of this solution, I think it's intuitive,
easy to implement and very effective.

Cheers
-- Stephan

---------------------------------------------------------------
Dr. Stephan Diehl Tel.: ++49-681/302-3915
EMAIL: diehl@cs.uni-sb.de WWW: http://www.rw.cdl.uni-saarland.de/private/diehl
---------------------------------------------------------------
There is no place like $HOME
---------------------------------------------------------------