Re: On Inheritance...

Johannes N. Johannsen (jojo@well.com)
Wed, 09 Apr 1997 10:20:30 +1200

Park SungWoo wrote:

> 1)
> Now, we want to define a new prototype similar to Robot, let's call it
> NewRobot. A NewRobot node has the same structure as Robot nodes. However,
> its event handler X actly slightly differently to Robot's handler X.
> Consider the following code :
>
> PROTO NewRobot extends Robot [
> eventIn SFInt32 X
> ] {
> HANDLER X {
> url "vrmlscript:
> function main(c,t) {
> // compute new 'rot' according to SFInt32 c
> // rot = g(c) for some function g()
> // g() != f()
> }
> "
> }
> }
>
> Class NewRobot has two fields, rot and clr, both of which are inherited
> from its super class Robot. Class NewRobot has overridden its superclass'
> handler X.
> Then, my question: In this proposal, prototype NewRobot declared
> eventIn SFInt32 X. Is is necessary ?? To Omit it is better ??
>
The thing that makes this hard to answer I think is that redeclaring the
"HANDLER X" overrides the base class "HANDLER X", but declaring
something else like the "Transform.." is not overriding the base class
Transform (is that correct?).

What would make it less confusing, at least to me, would be if the
HANDLER X syntax looked like code instead of nodes..., like

vrmlscript function handler_x(c,t) {
// compute new 'rot' according to SFInt32 c
// rot = g(c) for some function g()
// g() != f()
}

If it looked like this, then it would be like C++ or Java in that you
can tell data from code by the syntax. In that case, it would be easy
to say you don't need to declare the "eventIn".

JJ