RFC: New C++ Attribute: final

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Mar 1 18:56:00 GMT 2004


Joe Buck <Joe.Buck@synopsys.COM> writes:

| I first saw a proposal for "final" in C++ in the context of a paper on
| the implementation of matrix classes of various forms (sparse matrix,
| symmetrix matrix, general dense matrix, etc) in 1992.

Indeed, "final" has been repeatedly proposed for C++, repeatedly
discussed/debated, and repeatedly rejected.  It is proposed again for
the next round of C++ standardization. (I would not be surprised by
the outcome though ;-))  The guy working upstair said he had been
seeing that suggestion since CFront was released with support for
virtual fonctions :-)

comp.lang.c++.moderated and comp.std.c++ have plenty of those
discussions. 

|  The key observation
| is that if we make the base element access method virtual, but then make
| the derived element access methods final, we can write algorithms for the
| derived classes in a natural way and avoid virtual calls.  In the absence
| of "final", I've often been reduced to having two forms of calls, a
| virtual form and a nonvirtual form, which can be error-prone.

While not stating my opinion on that keyword, a frequent counter
argument (that I rather find persuasive) is that "final" when defended
as above is presented as a feature for "write-only codes with no proper
design".  

-- Gaby




More information about the Gcc mailing list