Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cwruecmp!neoucom!cbosgd!danews!lvc From: lvc@danews.UUCP (Larry Cipriani) Newsgroups: net.lang.c Subject: Re: Switch case common code - (without a function) Message-ID: <143@danews.UUCP> Date: Tue, 24-Jun-86 09:11:19 EDT Article-I.D.: danews.143 Posted: Tue Jun 24 09:11:19 1986 Date-Received: Thu, 26-Jun-86 04:21:44 EDT References: <605@cisden.UUCP> <134@danews.UUCP> <953@mmm.UUCP> Organization: AT&T Bell Labs, Columbus OH Lines: 40 > 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."