Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!visix!ip2020!adamksh From: adam@visix.com Newsgroups: comp.lang.c Subject: Re: Should I use macros to inline code? Message-ID: <1991Mar28.054111.1465@visix.com> Date: 28 Mar 91 05:41:11 GMT References: <1991Mar27.024602.21399@visix.com> <15601@smoke.brl.mil> Sender: news@visix.com Reply-To: adam@visix.com Organization: Visix Software Inc., Reston, VA Lines: 36 In article <1991Mar27.024602.21399@visix.com> I wrote: -> Assuming that's useful, is there any use for subroutines, so that a -> routine is only inlined once per function? : : -> (Actually, I don't see any way to pass arguments to and return from -> subroutines that would make them useful in C.) In article <15601@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) writes: > ??? Oops! Normally I am really quite intelligible, sorry about that. I've been playing with the idea of a toy preprocessor to provide some automagic premangling of my C source. Among other things, I thought it would be nice to automatically generate inlining macros from existing function definitions (if inlining is useful). Now, given inlining, I wondered, what if a two-line function gets inlined twenty times in one function? Wouldn't it be more efficient to inline the actual code only once, with a label, and then expand calls to it into goto's to the label? Since the goto itself doesn't push any arguments, I called this option a subroutine, out of analogy to BASIC's GOSUB. This gives the programmer three choices: inlining when time is a lot more important than memory subroutines when time is a little more important than memory functions when time is not more important than memory But subroutines look like a lot of trouble to implement, so before I even start thinking about it, I have to ask, is it worth it? Adam