Re: inheritance bug?

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

>>>What about doing #2 but allowing an optional override keyword if you
>>>want the compiler to check your spelling?
>>> 
>>>      
>>>
>>This sounds like a reasonable compromise.
>>    
>>
>
>Seems like a compiler switch to change the warning level, not language
>syntax.
>
>One motivation for virtual and override in C# was performance; 
>
Which is a very lame reason, and a huge step backwards. Clever JVMs or 
global optimizers can do that job automatically for you if really need 
it (and yes, that can be made to work with dynamic loading in the JVM).

>the
>other motivation was making it easier to ensure new code versions do
>not break, at the cost of making it more difficult to extend code in
>subclasses. http://www.artima.com/intv/nonvirtual.html
>  
>
That's a very good motivation. But 'override' itself solves that problem 
(or like suggest Brian, the oppose which is to make declarations), no 
need for 'virtual'.

The reason given for 'virtual' is that people might misuse overriding or 
underspecify virtual methods, which is true. But it's equally true that 
people can misuse non-virtual methods, by not making something 
overridable when it could/should be. The advantage of the first case is 
that at least the client can fix the problem. And the situation is 
greatly improved by the introduction of contracts (pre/post conditions), 
which they don't even mention.

>Been a little concerned about what it will be like fixing-up method
>declarations when hierarchies change in a codebase - the cost of having
>separate declarations and implementations. 
>
Sorry I lost you. The point of having separation is that you _don't_ 
need to fix anything when the hierarchy change, that's explained in the 
article. Did I miss something?

>(Really don't make typos in
>method names - copy and paste fixed that a longtime ago
>
Do you copy paste the name of every method you implement?

I agree that more advanted tools would make these decisions irrelevant. 
You'd be presented with a list of method, and could select which one you 
want to override, for what specialization of parameters.

>. Similarly edit
>replace fixed that problem for name changes.)
>  
>
Agreed with that one, especially with refactoring tools.

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.