Article View: comp.std.c++
Article #285Re: case()
From: Jeff Bilmes
Date: Wed, 08 Aug 1990 20:53
Date: Wed, 08 Aug 1990 20:53
32 lines
1582 bytes
1582 bytes
In article <26842@pasteur.Berkeley.EDU> krste@ICSI.Berkeley.EDU ( Krste Asanovic) writes:
>The C/C++ switch statement is very limited as it only allows integer
>expressions. I'd like to suggest a more general case statement.
>The syntax would be,
>
> case (exp) {
> case val1 : s1;
> case val2 : s2;
> default : sOther;
> }
>
> ...
I think this is unnecessary. C++ is already a large language and new
features which don't have important semantic advantages should
be avoided. The case statement you mention above would only add
type checking and non compile time constants "switched" on in a (I
presume) syntactically pleasing way. This does not warrant
extending the language when you can do the semantic equivalent as
easily as:
if (exp == val1)
s1
else if (exp == val2)
s2
else if (exp == val3 || exp == val4 || exp == val5 || ...)
s3
...
----------------------------------------------------------
Jeff Bilmes arpa: bilmes@icsi.berkeley.edu
uucp: ...!ucbvax!icsi!bilmes
Technical Details
Message-ID:
<26857@pasteur.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!ucsd!ucbvax!pasteur!icsib!bilmesReferences:
<26842@pasteur.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!ucsd!ucbvax!pasteur!icsib!bilmes From: bilmes@icsib.Berkeley.EDU (Jeff Bilmes) Newsgroups: comp.std.c++ Subject: Re: case() Keywords: case statement Message-ID: <26857@pasteur.Berkeley.EDU> Date: 8 Aug 90 20:53:20 GMT References: <26842@pasteur.Berkeley.EDU> Sender: news@pasteur.Berkeley.EDU Reply-To: bilmes@icsib (Jeff Bilmes) Organization: International Computer Science Institute, Berkeley, CA Lines: 32