Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!ulysses!fox From: fox@allegra.att.com (David Fox) Newsgroups: comp.lang.c++ Subject: Re: Request for C++ coding "guidelines" Message-ID: Date: 16 Feb 90 21:23:20 GMT References: <2754@arran.tcom.stc.co.uk> <25D0B18E.27508@paris.ics.uci.edu> <4446@pegasus.ATT.COM> <4843@helios.ee.lbl.gov> Sender: netnews@ulysses.att.com Organization: AT&T Bell Laboratories Lines: 34 In-reply-to: beard@ux1.lbl.gov's message of 14 Feb 90 03:36:17 GMT Patrick C Beard (beard@ux1.lbl.gov) 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. An inline only takes up space if you use it. A static always takes up space. If you use it zero times (the usual case, I contend), you win. > 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. I can't understand why people are so quick to tell people when and how to (or not to) use inline functions, and usually (as here) without any justification, apart from "they take up too much space". If you please, I'd like to be the judge of what is "too much space" on a case by case basis. Sometimes I'll make a piece of code into a subroutine that is only called once (or maybe twice), in order to elucidate the structure of the program. In this case it is appropriate to make even a hundred line function inline. Another reason I've heard for using inlines is to preserve locality of reference. These decisions should be up to programmers, not to guideline writers. David Fox fox@allegra.att.com -- We've all got opinions. Where do they come from?