Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!voder!decvax!roger From: roger@decvax.UUCP (Roger H. Scott) Newsgroups: comp.lang.c++ Subject: Re: Request for C++ coding "guidelines" Keywords: C++, inlines Message-ID: <84@pascal.decvax.UUCP> Date: 16 Feb 90 02:45:12 GMT References: <2754@arran.tcom.stc.co.uk> <25D0B18E.27508@paris.ics.uci.edu> <4446@pegasus.ATT.COM> <4843@helios.ee.lbl.gov> Reply-To: roger@procase.UUCP (Roger H. Scott) Organization: proCASE Corporation, Santa Clara, CA Lines: 59 In article <4843@helios.ee.lbl.gov> beard@ux1.lbl.gov (Patrick C Beard) writes: >... >Now hold on. The amount of space wasted by outlining inline functions >to static functions for every file that needs them will always be <= to >the code space taken by correctly inlining the function to begin with. >And will likely be much less. This statement is so wrong I don't even know where to begin tearing it appart. First of all, AT&T's translators generate "outline" version of inline functions that *aren't even called*. Are you trying to tell me that the amount of code generated for these is <= 0? Second, the object code generated for a *real function* is likely to be *at least* several instructions bigger than the code that would be generated inline. Thirdly, in some cases the size difference is huge (bordering on infinite ratio-wise). Consider the following: typedef unsigned n32; class Set32 { // set of up to 32 small integers (0<=i<=31) unsigned b; public: Set32(n32 i0 =32, n32 i1 =32, n32 i2 =32, n32 i3 =32, n32 i4 =32, n32 i5 =3, n32 i6 =32, n3 i7 =32) : b (((i0<32)?(1< So this brings to mind some guidelines for using inline member functions. > > 1. Inlines should be one line of code. [I use them mainly for read > only access to private or protected data]. > 2. Inlines should be simple. Simple rules for simple minds. The real world isn't so neat and tidy - guidelines based on the computation involved are much more meaningful. It sounds to me like Mr. Beard is talking off the top of his head here and hasn't actually observed or measured the problem under discussion. Correct me if I'm wrong.