Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!petrus!scherzo!allegra!mit-eddie!think!harvard!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: An amusing piece of code Message-ID: <360@hadron.UUCP> Date: Mon, 7-Apr-86 23:54:25 EST Article-I.D.: hadron.360 Posted: Mon Apr 7 23:54:25 1986 Date-Received: Thu, 10-Apr-86 01:19:07 EST References: <1370@ism780c.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 18 Summary: Jumping into blocks is a no-no. In article <1370@ism780c.UUCP> tim@ism780c.UUCP (Tim Smith) writes: > switch ( thing ) { >case A: A-code; break; >case B: B-code; if ( 0 ) { >case C: C-code; if ( 0 ) { >case D: D-code; }} > BCD-common-code; break; >case E: E-code; > } Assuming that you can't put BCD-common-code into a function, I agree with everyone else that you should use [forward-referencing!] goto's here, and [again] cite Prof. Knuth's _Structured_Programming_ _with_Goto's_. One major problem is that this code jumps into blocks [the effect of case C: and case D: ]. This is something that X3J11 warns about. I thought K&R did, too; but I can't find it. It is generally a bad practice, although most compilers seem to allow it without too much trouble.