Anil Philip
Posts: 19
Nickname: anilphilip
Registered: Nov, 2002
|
|
Re: rfe.request Java feature. enforce call to super.bar() with 'super' keyw
|
Posted: Jan 30, 2003 3:49 PM
|
|
Joan, Thanks for your reply. The use of the 'super' keyword in the declaration would be optional. But when it is used, it would ensure that the superclass method is called at some time. Just as we have keywords in the language to enforce some design 'wishes'.
eg. in C++, the use of 'const' (or 'final' in Java) for the parameters/return values makes them non-modifiable by the 'user' of the variables.
regards, Anil Philip
> Hello. It's a thoughtful suggestion, but it has two > drawbacks. The first is that it doesn't gain anything - in > order to place the call to 'super' properly, the > programmer has to understand what the over-ridden method > is doing, which is the same situation we have without the > additional keyword. The second problem is that sometimes > you need to short-circuit the usual behavior and *not* > call the superclass method. For example, usually event > listeners want to call the superclass and continue the > chain - but sometimes, it's important to consume the event > and interrupt the chain.
|
|