Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: comp.lang.c++ Subject: Re: Request for C++ coding "guidelines" Summary: inline 100 line functions? normally, no reason to bother... Message-ID: <1644@aber-cs.UUCP> Date: 18 Feb 90 19:12:33 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 30 In article fox@allegra.att.com (David Fox) writes: 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. Well, one of the main reasons for inlines does not apply; for a large function, call return overhead is going to be insignificant. And doing large inlines taxes the *compiler*. On the other hand, I admit to the same practice (but only occasionally)... even if I think it is pretty pointless. Another reason I've heard for using inlines is to preserve locality of reference. Or, even more strongly, allowing code simplification. But I could leave to the programmer, actually. These decisions should be up to programmers, not to guideline writers. Hey, if you *know* what you are doing, a guideline is not a rule! :-). Another thought: I actually think that inline could usefully be split in two keywords; 'inlinable' applied to functions, and 'inline' applied to their calls. It is not always worth it to inline expand a function at every one of its calls. But maybe this is splitting hairs too finely... -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk