Switch case common code - (without a function)

Larry Cipriani lvc at danews.UUCP
Tue Jun 24 23:11:19 AEST 1986


> int common_stuff()
> {
> 	blahblahblah
> }
> 
> main()
> {
> ...
> 	switch (thnad) {
> 	case A:
> 		do the A stuff;
> 		common_stuff();
> 		break;
> 	case B:
> 		do the B stuff;
> 		common_stuff();
> 		break;
> 	case C:
> 		do the C stuff;
> 		break;
> 	}
> 
> I thought that's what functions were for.
> 
> 	--MKR

One of the requirements of the original request is that
a function not be used.

A reason not to use a function is that the scoping rules
get in the way, and force one to either use lots of global
varibles (yuck) or pass the function addresses of variables
and manipulate them through indirection (still yucky).

Another is that in a realtime process you might want to keep
the number of function calls to a minimum.
-- 

Larry Cipriani		AT&T Network Systems
danews!lvc		"Nothing is worse than an itch you can never scratch."



More information about the Comp.lang.c mailing list