break <label> and another use for goto's.

Frank Adrian franka at hercules.UUCP
Wed Jan 16 01:44:49 AEST 1985


In article <4913 at utzoo.UUCP> henry at utzoo.UUCP (Henry Spencer) writes:
>> While scanning the source of a module done by one of
>> my collegues, I noticed a label at the start of a module.
>> "Why did you need a goto here?"
>> 
>> His reply was that he uses
>> 
>> 	label:	...
>> 		goto label;
>> 
>> to delimit an outer loop that goes on for several pages as
>> you can easily lose visual track of {...} nesting levels.
>
>The right comment on this is "why don't you split that loop body
>up into separate functions, as God clearly intended?" :-).  If it's
>long enough to make tracking indenting levels difficult, it's too
>long to be in one monolithic piece.
>-- 
Unfortunately, Henry, things aren't always that simple.  If one is
dealing with time critical or often used code within a loop, the
overhead inccurred with all of the procedure calls can add up.
I once shaved 30% execution time off a program by expanding a routine
call in an often traversed loop.  Funny, it didn't seem to make the
program more readable.  Well, I guess that's the breaks.  The point
is that sometimes execution speeds are critical and "good" coding
style gets in the way of speed.  That is unless you find me a C
compiler which automatically does inline routine expansion.  Now
if you would have suggested using macros...
				"Rules are made to be broken..."
					Frank Adrian



More information about the Comp.lang.c mailing list