Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!yetti!geac!daveb From: daveb@geac.UUCP (Brown) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <1100@geac.UUCP> Date: Wed, 12-Aug-87 08:34:59 EDT Article-I.D.: geac.1100 Posted: Wed Aug 12 08:34:59 1987 Date-Received: Fri, 14-Aug-87 04:10:28 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <1032@ius1.cs.cmu.edu> Reply-To: daveb@geac.UUCP (Dave Brown) Organization: The little blue rock next to that twinkly star. Lines: 46 Summary: for C[2] (or P), we can restrict the range of gotos In article <1032@ius1.cs.cmu.edu> edw@ius1.cs.cmu.edu (Eddie Wyatt) writes: >In article <916@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes: >> In article <2683@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: >> >What bothers me is that I can't say ["goto default" and "goto case N"]. >> Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint > > Consider the problems "goto case N" cause when there are two switch >statements each with a case N label in the function block. > Eddie Wyatt This is NOT a proposal for C (its for P, as in BCPL). One should restrict the range of gotos referring to switch/case/whatever labels to the body of the switch, as in: ... switch (foo) { case 'a': a(bar); -- note no fall-through case 'f' | 'e': -- one possible syntax... f(foo,bar); goto case 'a'; -- another possible syntax case DEL: goto crash; } ... unwind(); return bar; crash: partially_unwind(); return ERR; A "goto case x" outside a switch would be an error. --dave -- David Collier-Brown. | Computer Science Geac Computers International Inc., | loses its memory 350 Steelcase Road,Markham, Ontario, | (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.