Re: On Inheritance...

Park SungWoo (gladius@compiler.kaist.ac.kr)
Thu, 10 Apr 1997 08:09:53 +0900 (KST)

>
> Park SungWoo wrote:
>
> > ...
> > 1)
> > In class NewRobot, we want the HANDLER X to be redefined. Hence, as you
> > may think, the re-declaration of eventIn X is redundant and unnecessary.
> > Then, prototype NewProto would be shown as below.
> > What I fear about is that in this case, the prototype NewProto may
> > be sometimes confusing. For, at first glance, there is no corresponding
> > eventIn declared. Am I right?? or is it just groundless fear ???
> >
> Let me restate my confusion... it is not related so much to whether you
> declare the eventIn X or not. It is related to how do you know whether
> what you are declaring overrides a previous declaration vs. accumulates
> in the object. In Java/C++, data members accumulate, methods get
> overridden. So what confuses me about a declaration like: "eventIn
> SFInt32 X" is that it is saying to me -- this is data, it accumulates.
> But then it is associated with a HANDLER X, which overrides.
>
> So which is it? The answer seems to be that the "eventIn SFInt32 X" and
> the "HANDLER X" both override base class info.
>
> Going by the usual Java cues confused me here, but it was the best I
> could do. I understand the conventions now (please let me know if I
> don't).
>
> JJ
>

1)
I treated eventIn's just as tags for event handlers up to now. That is,
I intended that they should be used only to indicate event types.
>From your comments, I found it was a reckless decision.

Hence, if we adopt event handler approach, we should specify whether
eventIn's are regarded as data or not.
If we treat them as data, then, as you indicated, re-declaration of
the eventIn is unnecessary. Else, we re-declare it.

Which is the better ??? (Note: PROTO == CLASS in VRML++)

Candidate 1)

PROTO NewRobot extends Robot [
eventIn SFInt32 X
] {
HANDLER X {
url "vrmlscript:
function main(c,t) { ... }
"
}
}

Candidate 2)

PROTO NewRobot extends Robot [
] {
HANDLER X {
url "vrmlscript:
function main(c,t) { ... }
"
}
}

In my opinion, the second is better because it is natural to consider
eventIn's as data such as eventOut, field.

2)
In the above example, the handler X receives events of type SFInt32.
If a new event handler X which receives events of type SFFloat
is to be defined in NewRobot, we must declare explicitly a
corresponding eventIn as shown below:

PROTO NewRobot extends Robot [
eventIn SFFloat X
] {
HANDLER X {
url "vrmlscript:
function main(c,t) { ... }
"
}
}

Then, the previous event handler X which processes SFInt32 events is lost.
Is it a serious problem, or is it OK to ignore it ???

Thanks. My sleeping time AM 8:00 has come. I go...

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 Sungwoo Park, (Castle-Help Naive)
	homepage : http://compiler.kaist.ac.kr/~gladius
 	e-mail : gladius@compiler.kaist.ac.kr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -