Re: inheritance bug?

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
[email protected] wrote:

>This was discussed on the mailing list in the covariant return type thread, I
>believe. When you specify a return type, you are overloading the method. In
>order to _override_ the method, you need to leave the return type off.
>  
>
Right.

Once again we can see the confusion this creates. I think it this case 
it should either:

1) signal an error because you are overloading a method in a more 
specific case. You could then explicitely state that you override it 
with the 'override' keyword (especially if you want to covariantly 
specialize the return type) or simply delete the return type.

2) silently override the initial method. This is Java's behaviour. So 
that's more intuitive to Java developers, and ligther syntax (but only 
when you need to specialize the return type, which is probably rare). On 
the other hand, it bears the risk of silently not overriding if you make 
a typo in the method's name, and hides the fact to the reader that you 
are actually overriding a method.

Daniel



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.