This is the mail archive of the
mailing list for the GCC project.
Re: RFC: New C++ Attribute: final
- From: Matt Austern <austern at apple dot com>
- To: Kevin Atkinson <kevina at gnu dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 2 Mar 2004 12:57:21 -0800
- Subject: Re: RFC: New C++ Attribute: final
- References: <Pine.LNX.firstname.lastname@example.org>
On Feb 28, 2004, at 6:43 PM, Kevin Atkinson wrote:
I have an idea for a new C++ attribute, and would like to know what
think of it:
Marks a virtual function of an entire class as being "final", in the
that it can not be overridden in a derived class. If it is applied to
type then every virtual function in the class will be considered final.
It will not, however, keep a class from being inherited from.
Gcc will produce a warning (or maybe an error) if a "final" method is
The primary purpose of this attribute is to serve as an optimization
so that a virtual function call does not need to be used. It will also
allow gcc to perhaps inline the function call if it is appropriate.
My opinion is that this would be better sent to the C++ standards
committee than to the gcc mailing list. That is: I would be much
happier if this were part of portable C++ than if we put it in as an
ad hoc extension.
Rationale: our experiences with language-design-by-compiler
have been mixed. It's unlikely that we'll be able to get all of the
corner cases on a new language feature right if we just say "this
feature should do thus-and-such for this example", because we
have to know what it does for code other than whatever is in a
finite number of examples. And C++ is a complicated enough
language that a new feature is likely to have corner cases and
non-obvious interactions with other features, even if it seems
simple at first.