Re: [sv-ec] Abstract classes and virtual methods

From: Neil Korpusik <Neil.Korpusik_at_.....>
Date: Mon Feb 13 2006 - 09:26:13 PST
Gordon Vreugdenhil wrote On 02/04/06 21:34,:
>>4. Optional 'virtual' keyword
>>
>>   Page 2, first paragraph.
>>
>>   "Once a method has been identified as virtual, it shall remain virtual in
>>   any subclass that overrides it. The virtual keyword may be used in later
>>   declarations, but is not required."
>>
>>   This appears to be an enhancement. Not only that, I don't believe that we
>>   want to add this capability. It should be up to the user to determine if
>>   a method should be virtual or not.
>>
>>Neil
> 
> 
> 
> Neil, do I understand that you want to require the user to
> have an explicit "virtual" in every derivative class?  

Yes, that is what I proposed.

> What
> if the user does not use the word "virtual" if the base has
> a virtual method?  Does that hide the inherited one or is that
> an error?

It would not be an error to leave off the word 'virtual' in a subclass.
It would override the virtual method in the base class just like it
would for any other virtual method. The difference would be that
this method would no longer be virtual for
any classes derrived from this subclass.

> 
> I don't see any particular problem with not requiring "virtual"
> for virtual overrides in derivative classes.
> 

It looks like we have a choice of two existing strategies for handling
this situation.

I checked the 1998 version of the ISO/IEC C++ standard to see what it had
to say on this matter. It was quite clear that what Dave has proposed is
indeed the way that virtual member functions are handled in C++. See section
10.3 Virtual functions.

I checked the OpenVera documentation but was unable to find sufficient details
on this to definitively say which way it should work in Vera. I wrote a
small vera example and observe that it works in a manner similar to what I
was suggesting in my post to the reflector.

That leaves us with two existing implemetations to coose from. Orgininally
I was thinking that C++ and Vera treated virtual methods the same way. I now
realize that they don't.




-- 
---------------------------------------------------------------------
Neil Korpusik                                     Tel: 408-720-4852
Senior Staff Engineer                             Fax: 408-720-4850
Frontend Technologies - ASICs & Processors (FTAP)
Sun Microsystems
email: neil.korpusik@sun.com
---------------------------------------------------------------------
Received on Mon Feb 13 09:27:46 2006

This archive was generated by hypermail 2.1.8 : Mon Feb 13 2006 - 09:28:39 PST