[comp.lang.c++] Request for C++ coding "guideli

stt@inmet.inmet.com (02/16/90)

With regard to multiple copies of "out-lined" inline functions...

A much simpler algorithm, though admittedly not optimal,
is to always emit code for the out-lined version in
the same place that the vtable would be emitted.
This way, there is never more
than one copy of the out-lined version (presuming the
C++ 2.0 vtable mechanism works properly).  

Of course, there is never *less* than one copy either, but
generally inlined routines are small, and they only
become a space problem when they are duplicated many times
due to the current drop-them-where-they-are-called approach.

By the way, most Ada compilers/linkers have gone over to an
approach where each function and each large static data structure
is in its own object module "section", and the linker only
includes referenced sections in the final executable image.
This approach is similar to that proposed, but is more
general, and is essential for large reusable packages/classes
where any given re-user only needs a relatively small proportion
of the functions.  

C++ Vtables complicate this of course,
by creating references to all virtual function bodies, and
additional complexity in the compiler/linker would be necessary
to eliminate virtual functions which could never be reached.

S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA  02138

roger@procase.UUCP (Roger H. Scott) (02/20/90)

In article <21000008@inmet> stt@inmet.inmet.com writes:
>With regard to multiple copies of "out-lined" inline functions...
>...
>always emit code for the out-lined version in
>the same place that the vtable would be emitted.
>...
>Of course, there is never *less* than one copy either,

Unfortunately this last statement is untrue.  Structs/classes with no
virtual functions don't have vtbls - where do their outlined inlines go?
Here we have yet more evidence that structs should have been left alone as
they are in C and classes should have been gotten all the goodies, including
default virtual functions.