Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!oddjob!gargoyle!ihnp4!inuxc!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <997@bsu-cs.UUCP> Date: Wed, 31-Dec-69 18:59:59 EDT Article-I.D.: bsu-cs.997 Posted: Wed Dec 31 18:59:59 1969 Date-Received: Sat, 22-Aug-87 04:18:39 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <298@auvax.UUCP> <10265@orchid.waterloo.edu> <6289@brl-smoke.ARPA> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 47 Summary: treat characters as integers In article <6289@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes (about "case 'a' :: 'z' :" and similar ranges in case statements): There's another serious problem underlying all these suggestions; namely, that "a through z" has a well-defined meaning [especially in an international setting]. The only well-defined ordering I think could be used meaningfully in a standard would have to be the native run-time collating sequence based on fixed-size letter units. It seems simplest to me to stay with the character-is-integer paradigm and treat each constant used to specify the range as an integer. (I note that K&R specifically say on page 202 that the 'constant- expression' in a switch statement must be int.) One thing I expect to always be true for C, even as it evolves to accomodate different character sets, is that each distinct character constant will correspond to a distinct int value. Otherwise a lot of code would break badly, not to mention K&R's entire book. Then the range is always well-defined, except that the compiler would warn about empty ranges. Also, the compiler would probably need to warn about overlapping ranges. Much of the time, when a range like this is used in a switch statement, the user is thinking of a fast jump table implementation rather than an if-then-else. It's up to the user to make sure this makes sense, even if the character set has holes. Here's an aside not directed at anybody in particuler. I think that for too long language designers have tried to accomodate the vagaries of EBCDIC, specifically, that it's a character set with holes. Must every language accomodate every whim and fancy of every badly-designed architecture? The answer ought to be a resounding no. The general principle is quite simple: Those who choose to use badly-designed machines should have to bear the burden of doing so without dragging the rest of us down with them. The six-character limit on external names (I hope it's gone from the draft now) is another example of not applying this philosophy. Why does it make any sense for the rest of the world have to suffer from the limitations of old linkers on old machines from the sixties? We should certainly make an effort to accomodate all widely-used architectures, but not at the expense of seriously distorting the language for everybody else. -- Rahul Dhesi UUCP: {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi