Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!att!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Efficiency of Multiple Inheritance Message-ID: <9466@alice.UUCP> Date: 12 Jun 89 13:40:57 GMT References: <1484@bacchus.dec.com> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 29 In article <1484@bacchus.dec.com>, bothner@decwrl.dec.com (Per Bothner) writes: > If one adds a feature to a language, a general goal is that > a user should only have to pay to cost of the feature when > using it. Adding multiple inheritance to C++ violates this > rule: Now \every/ virtual function call must do an extra addition, > to adjust the 'this' pointer properly. This is an implementation issue, not as a language issue, as you point out yourself later on... > An alternative is to have the \called/ routine do the adjustment, > instead of the \caller/. The trick is to have stub routines, > which adjust 'this' and then jump to the real routine. The main problem with your scheme is that it becomes hard to generate code for these stub functions when they contain s `...' argument list. The stub may have to copy the whole argument list, but it doesn't know how big it is! There's no problem generating machine language code do it for most machines, but we haven't been able to figure out how to generate appropriate C that has any chance of running on more than one machine. Therefore cfront takes the porable route despite the slight overhead; presumably other, more machine-dependent implementations will choose the most efficient route for their machine. -- --Andrew Koenig ark@europa.att.com