Path: utzoo!attcan!uunet!munnari.oz.au!uhccux!ames!apple!voder!procase!roger From: roger@procase.UUCP (Roger H. Scott) Newsgroups: comp.lang.c++ Subject: Re: renaming Message-ID: <156@logo.procase.UUCP> Date: 1 Jun 90 07:03:30 GMT Reply-To: roger@procase.UUCP (Roger H. Scott) Organization: none Lines: 90 Newsgroups: comp.lang.c++ Subject: Re: renaming Summary: Expires: References: <18591@orstcs.CS.ORST.EDU> <228@taumet.COM> Sender: Reply-To: roger@procase.UUCP (Roger H. Scott) Followup-To: Distribution: Organization: proCASE Corporation, Santa Clara, CA Keywords: In article <228@taumet.COM> steve@taumet.UUCP (Stephen Clamage) writes: >In article <18591@orstcs.CS.ORST.EDU> budd@mist.CS.ORST.EDU (Tim Budd) writes: >> void gak(int i) { bar::geek(i); } >>introduce[s] the run-time overhead of one additional function invocation. > >I know of no C++ compiler which would not inline this member function, >and it seems unlikely that any ever would refuse to do so. It seems >unnecessary to introduce a new language feature, thus complicating *all* >compilers, to make things simpler for users stuck with bad compilers. > >If your local C++ compiler won't inline such a simple function (meaning >no overhead whatsoever), try to get another one. Such a compiler is >bound to be woefully deficient in other ways. >-- > >Steve Clamage, TauMetric Corp, steve@taumet.com Don't you guys *build* C++ compilers? Consider the following: #define redefine struct Base { ... virtual void f(); void implementation1_of_f(); void implementation2_of_f(); }; struct Der1 : public Base { redefine void f() {implementation1_of_f();} }; struct Der2 : public Base { redefine void f() {implementation2_of_f();} }; Are you telling me that you are going to inline Der1::f and Der2::f, both of which are *virtual*? Another example (with MI): struct AbstractThing { ... virtual void f(); }; struct Thing1Implementation { void do_that_there_f_stuff(); ... }; struct Thing2Implementation { void do_that_there_f_stuff(); ... }; struct Thing1 : public AbstractThing, public Thing1Implementation { redefine void f() {do_that_there_f_stuff();} }; struct Thing2 : public AbstractThing, public Thing2Implementation { redefine void f() {do_that_there_f_stuff();} }; Again, how are Thing1::f and Thing2::f going to be inline? It seems like a reasonable generalization of the syntax (and semantics?) of pure virtual functions would be to allow: struct Thing1 : public AbstractThing, public Thing1Implementation { redefine void f() = do_that_there_f_stuff; }; where the "initializer" of the (member) function declaration would be required to be type compatible with the thing that it is initializing, i.e. a member function of the same class or a public base that took the same arguments and returned the same type. The implementation of this is trivial - put the address of the "initializing" function into the vtbl rather than that of a new function.