Path: utzoo!attcan!uunet!microsoft!bobatk From: bobatk@microsoft.UUCP (Bob ATKINSON) Newsgroups: comp.std.c++ Subject: Re: case() Keywords: case statement Message-ID: <56515@microsoft.UUCP> Date: 13 Aug 90 18:12:18 GMT References: <26842@pasteur.Berkeley.EDU> <26857@pasteur.Berkeley.EDU> Reply-To: bobatk@microsoft.UUCP (Bob ATKINSON) Organization: Microsoft Corp., Redmond WA Lines: 31 In article <26857@pasteur.Berkeley.EDU> bilmes@icsib (Jeff Bilmes) writes: >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. ... > >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 > ... By this logic, switch statements should not have been invented in the first place. Clearly in C a need was felt for this syntactic sugar. Krste was merely pointing out that one can argue that the same needs can motivate a similar extension for non-integral types, of which there are a significantly larger number in C++ (that have equality operators) than in C. I guess I don't feel particularly strongly about this issue; I just felt the reasoning being used was flawed. Bob Atkinson Microsoft