Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!oberon!cit-vax!ucla-cs!zen!ucbvax!decvax!tektronix!teklds!zeus!tekla!dant From: dant@tekla.TEK.COM (Dan Tilque;1893;92-789;LP=A;60HC) Newsgroups: comp.lang.c Subject: Re: gotos and switch statements -- mild proposal Message-ID: <2274@zeus.TEK.COM> Date: Sun, 23-Aug-87 08:31:28 EDT Article-I.D.: zeus.2274 Posted: Sun Aug 23 08:31:28 1987 Date-Received: Sun, 23-Aug-87 22:35:28 EDT References: <855@tjalk.cs.vu.nl> Sender: news@zeus.TEK.COM Reply-To: dant@tekla.UUCP (Dan Tilque) Organization: First National Security Trust Bar and Grill Lines: 51 Peter da Silva writes: >First of all, I'd like to say that anyone who doesn't like the current >semantics for switch statements is a wimp and a pascal fanatic, but since >I'm a nice guy I won't. I'm glad I'm not a wimp, then. (Actually, I like the current semantics and am somewhat of an anti-gotoist, which is why I don't like the alternatives proposed.) >How about the following: > >#define CASE(x) switch(x) { >#define OF(y) break; case y: y: ; >#define ESAC } > >Now you can gross everyone out: Including the compiler: #define SPACE ' ' /* or most other representations of space that I can think of */ > CASE(c) > OF(NEWLINE) > blah blah blah; > OF(TAB) > goto SPACE; > OF(SPACE) > blah blah blah wow; > ESAC syntax error >This shouldn't be inefficient if you have a halfway decent compiler. A decent compiler is one that reads my mind so that it knows what my code is supposed to do. (However they still haven't gotten the bugs out of the telepathy peripheral yet.) A halfway decent one has more explicit error messages than "syntax error". >Happy? Not until I get a decent compiler. --- Dan Tilque dant@tekla.tek.com or dant@tekla.UUCP