home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!stanford.edu!EE.Stanford.EDU!sierra!mcgrant
- From: mcgrant@rascals.stanford.edu (Michael C. Grant)
- Subject: Re: Proposal - enhancement for switch statement.
- In-Reply-To: pete@cssc-syd.tansu.com.au's message of Sun, 15 Nov 1992 19:08:30 GMT
- Message-ID: <MCGRANT.92Nov15132747@rascals.stanford.edu>
- Sender: usenet@EE.Stanford.EDU (Usenet)
- Organization: Information Systems Laboratory, Stanford University
- References: <1992Nov15.190830.11622@cssc-syd.tansu.com.au>
- Date: 15 Nov 92 13:27:47
- Lines: 23
-
- In article <1992Nov15.190830.11622@cssc-syd.tansu.com.au>
- pete@cssc-syd.tansu.com.au (Peter Alexander Merel) writes:
- Before I describe what occurred to me, yes folks I know that a switch is not
- as useful as a virtual function.
- But what I'd like for a snippet I'm working on at the moment would be for
- switch to use operator== rather than relying on conversion to int, so that
- I could use it to test cases on objects rather than building an industrial
- strength if statement.
- And no, the class in question won't go onto int.
- This should be language compatible with the C usage, and not too hard
- for translaters to do just by translating into the aforementioned
- industrial if.
- Any chance?
-
- I doubt it... Even before C++ came along, switch statements could not
- handle floats, strings, structures, etc. Sure, a switch statement could
- be turned into a set of if-then-else statements, but it isn't because
- it usually is best turned into a jump table.
-
- I wouldn't object to such an addition in principle, except for the fact
- that it's unnecessary (a big objection for sure).
-
- Michael C. Ggrant
-