This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: New C++ Attribute: final
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Jeff Sturm <jsturm at one-point dot com>, Nathan Sidwell <nathan at codesourcery dot com>, Kevin Atkinson <kevina at gnu dot org>, Mark Mielke <mark at mark dot mielke dot cc>, <gcc at gcc dot gnu dot org>
- Date: 02 Mar 2004 13:59:11 -0300
- Subject: Re: RFC: New C++ Attribute: final
- Organization: Red Hat Global Engineering Services Compiler Team
- References: <Pine.LNX.4.44.0403011020550.11117-100000@ops2.one-point.com><m3n070e4cn.fsf@uniton.integrable-solutions.net>
On Mar 1, 2004, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Jeff Sturm <jsturm@one-point.com> writes:
> | > 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.
> There is no doubt that people will construct examples where they
> think they need final for C++.
One of them will probably have to do with passing pointers to member
functions to STL algorithms. There's no way in C++ that I know to
create a pointer to member that doesn't undergo virtual method
dispatch if the named method turns out to be virtual. Sure you can
introduce a separate private method and not only call it from the
virtual method, but also use it when you need a non-dynamic pointer to
method, but you have to hope nobody ever decides to introduce a
virtual method in a base class using the same name, to enable a
derived class to preempt your wish for a non-virtual pointer to
method.
Not that I personally find the need for non-virtual pointers to
members in good designs. It's just that, if final is added to C++,
people will probably want to annotate expressions that take the
address of member functions, and from that even function calls as
final! The horror! :-) :-)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Happy GNU Year! oliva@{lsd.ic.unicamp.br, gnu.org}
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist Professional serial bug killer