Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <930@haddock.ISC.COM> Date: Wed, 12-Aug-87 17:23:26 EDT Article-I.D.: haddock.930 Posted: Wed Aug 12 17:23:26 1987 Date-Received: Sat, 15-Aug-87 02:21:10 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <1032@ius1.cs.cmu.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 25 [Context: karl@haddock suggested that switch labels should behave more like normal labels; and that the latter should have to be declared, giving them block scope; and a bunch of related ideas.] In article <1032@ius1.cs.cmu.edu> edw@ius1.cs.cmu.edu (Eddie Wyatt) writes: >Consider the problems "goto case N" cause when there are two switch >statements each with a case N label in the function block. The solution is for the scope of a switch label to be the switch statement itself. Thus in the example posted in another article by ron@topaz, you get an error message from the compiler. If the switch statements are nested, you get the innermost enclosing one. >Also just consider how you would implement the two switch statements each >with a case N label. Since each label is a posible target of a goto, it must >be put into a label table for that function block. Now you have multiple >defined labels (label N) unless you do a few ugly things to uniquely define >each label - but then look up on labels become more expensive. I don't see that this is any worse than the current situation with variables: "{ int i; ... { double i; ... i=0; } }". In fact, by removing the special case (currently, labels are the only things that have function scope) it's possible that this would simplify the compiler. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint