This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: New C++ Attribute: final
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: Kevin Atkinson <kevina at gnu dot org>, Mark Mielke <mark at mark dot mielke dot cc>, <gcc at gcc dot gnu dot org>
- Date: Mon, 1 Mar 2004 14:39:45 -0500 (EST)
- Subject: Re: RFC: New C++ Attribute: final
On Mon, 1 Mar 2004, Nathan Sidwell wrote:
> Jeff Sturm wrote:
> > If a base class declares a method 'virtual' in C++, can a derived class
> > override the modifier, such that calls to the overridden method do
> > not require vtable dispatch?
> Only when the dynamic type can be determined at compile time.
I see...
> From a programmer's perspective, why is it desirable to remove the
> virtuality?
For C++, I can't think of a good reason besides performance. In Java, I
think 'final' is essential to the security framework.
In practice we often use 'final' to trigger a compilation error if someone
tries to override a method we wouldn't normally expect to be overridden,
if only to force the developer to examine it closely. However the first
time someone removes the final modifier, we lose that benefit.
Jeff