This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: New C++ Attribute: final


Alexandre Oliva <aoliva@redhat.com> writes:

| On Mar  2, 2004, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| 
| > Taking a pointer-to-member is a very *general* mechanism, that comes
| > with its price.  And in pratice, it is far more efficient (whether the
| > member function is virtual or not is immaterial) just to use custom
| > function objects that directly call the function: You get far *better*
| > efficiency.  
|      
| But then you can't use a generic template class to implement this
| object, which makes it far more cumbersome.

The function is certainly not generic, so what is the problem?

| > When you create a pointer to member function, the member
| > function does not need to be virtual
| 
| Certainly not.  But if such a pointer to member was final and bound to

But, the pointer to member is a *constant*, in a given scope with
defined lifetime.  That GCC does not take advantage of that is another
problem. 

| a known function, GCC might be able to short-curcuit function calls
| through it, and even inline them.

But we already have concrete situations with all the implied semantics
constraints and yet GCC fails to to do proper job.  Local class.

I'm not saying final is bad, I'm merely pointing out that facts.

| But since, for a virtual function,
| it is not possible to know the exact function that is going to be
| called unless you happen to know the dynamic type of the object, you
| lose.  With final, you'd win.
| 
| > People keep damaging codes -- in the name of whatever (usually,
| > generality).  I believe people  who damage their codes get what they
| > deserve :-) 
| 
| > With the help of final or not, people are going to damage their codes
| > anyway :-)  
| 
| So what do you propose?

Education :-) 

| Not to use C++? 

You don't need C++; it is just a useful tool :-) 
You can write useful software in other programming languages; you can
damage codes in other programming languages too.

| Not to use any programming language? :-) :-)

Stroustrup has an interesting chapter on "what programming at all?" in
his third edition :-)


Don't try to put in me in the camp of the "anti-final"s ;-/

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]