in-line functions

Chris Torek chris at umcp-cs.UUCP
Sat Feb 9 13:24:59 AEST 1985


jss at sjuvax (J. Shapiro) suggests that we consider inline functions,
rather than ridiculously complex macros.  It's a good idea.  MESA has
an INLINE keyword which does the obvious thing.  One could use
``register'' functions in C to do the same thing.

One point (which is obvious when you think about it) is that the
function definition must be available to all routines that use it; the
straightforward approach of generating no code for a register function
breaks the existing scope rules in C.  Two solutions come to mind:
either put the definition in a header file (which might fail if
compilers were allowed to ignore the register keyword when applied to
functions), or instead, generate code but expand in-line anyway (that
is, for

	register foo() {
		return bar();
	}

generate a true foo function, but just call bar() directly for
instances of calls to foo() within the rest of that source file).

Unfortunately, this defeats the purpose of register functions if they
are to be called from outside that particular source file, and adds
extra space if they are not.  (One could use "static register foo()"
functions, but this seems to be getting ridiculous...)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list