RFC: New C++ Attribute: final

Chris Lattner sabre@nondot.org
Mon Mar 1 19:34:00 GMT 2004


> Every problem in computer science can be solved by an extra level of
> indirection.  Or rather, every problem other than inadequate
> performance. Such claims usually come from those who follow rigid
> ideological approaches to object-oriented design.

Speaking from the perspective of a developer that writes a lot of C++
code, I totally agree with your viewpoint.  There _are_ workarounds that
don't cause code duplication (in the derived class, have a non-virtual
method do the work, and have the virtual one just call it), but these are
really gross and seemingly against the spirit of C++.

Also, it's not feasible to make all of the clients know about this
distinction, and if it changes over time, it's not scalable to modify tons
of client code where we could just modify one declaration in the header.
Also, if the client code is really a template using std::mem_fun or
something, it's not *possible* to change the client (without even more
gross hacks I suppose).

In my situation, I have complete control over the class hierarchy and if a
new subclass needs to be added, it's ok to remove the attribute and force
clients to recompile.  Though not everyone is in this situation, many are,
and it seems very reasonable to support it directly: even as a GCC
extension.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



More information about the Gcc mailing list