Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!ogicse!emory!hubcap!billwolf%hazel.cs.clemson.edu From: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe, 2847 ) Newsgroups: comp.lang.c Subject: Re: problems/risks due to programming language Message-ID: <8145@hubcap.clemson.edu> Date: 25 Feb 90 00:42:57 GMT References: Sender: news@hubcap.clemson.edu Reply-To: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu Lines: 34 From peter@ficc.uu.net (Peter da Silva): > On the other hand, the people (inlcuding Bill) arguing that switch...break > is an unalloyed disaster are also all wet. The C SWITCH is not a Pascal > CASE, it's a computed goto: [Fallthrough example] Which, amazingly enough, I explicitly noted in my original article: [...] In C, the case statement *requires* the use of a restricted GOTO in order to accomplish "normal" processing; at the end of the section of code processing a given case, one must use a restricted GOTO in order to prevent C from sending the flow of control straight into the section of code which was intended to process the NEXT case. In other words, C requires the programmer to use a dangerous construct on a routine basis. Many (including Peter) have re-observed that this is the way C's switch currently operates, but to date nobody has provided any justification for having it continue to operate that way. Apparently the thinking is that if the current definition is repeated often enough, it will be accepted regardless of how completely bizarre it is. Given the fact that switch..break results in the generation of many unnecessary lines of "break" code, that it requires its users to get into the habit of using a restricted GOTO to accomplish "normal" processing (the expensive nature of this habit being dramatically demonstrated by the recent nationwide AT&T crash), and that there is a widely used (and considerably safer) alternative, it would seem that C would be considerably better off if it were to either redefine or replace its switch construct with a case statement. Bill Wolfe, wtwolfe@hubcap.clemson.edu P.S. Pending this change, feel free to use Ada instead... :^)