Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!munnari!uqcspe!bunyip!uqvax!phcoates From: phcoates@uqvax.decnet.uq.oz Newsgroups: comp.lang.c++ Subject: Re: Improved switch statement Message-ID: <1031@uqvax.decnet.uq.oz> Date: 30 Dec 88 16:15:33 GMT Organization: University Of Queensland Lines: 32 In article <9276@ihlpb.ATT.COM> nevin1@ihlpb.ATT.COM(Nevin Liber) writes: |BTW, all of this is irrelevant to the original discussion. The point |is that, whether or not we like it, C++ allows you to define an operator |just about any way you want. The only useful way to used the proposed |change to the switch statement requires that I know exactly how it gets |rewritten as an if-then-else chain, in which case I would rather use the |if-then-else chain, since it is more 'self-documenting'. I like code to be consistent. I could quite easily live with a 'switch' statement that used the current definition of '=='. However I understand that, to account for those individuals who might use the above operator in some new and unknown way (and *then* think that they can get away with using a 'switch' with an instance of their new Mickey Mouse class as the selector or as a case label), a 'switch' structure based on '==' could be inferior to using if (...) { } else if (...) { /* etc. */ } else { } If so, then why bother to keep the switch statement at all? Must C++ be chained to its ancestry if it is better that it fly free? Surely if the 'if' is better then any program would be more 'self-documenting' if all such selections were treated using 'if' constructs. It comes down to this - either have a 'switch' that uses '==', or get rid of 'switch' all together. You can't stand with one foot on either side of a barbed-wire fence. Tony Coates.