Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!claris!apple!lenoil
From: lenoil@Apple.COM (Robert Lenoil)
Newsgroups: comp.std.c
Subject: Re: switch (expression)
Message-ID: <14036@apple.Apple.COM>
Date: 15 Jul 88 22:32:12 GMT
References: <1988Jul12.105547.13268@light.uucp>
Reply-To: lenoil@apple.apple.com.UUCP (Robert Lenoil)
Organization: Apple Computer Inc, Cupertino, CA
Lines: 14

More basic than pointers, how about allowing other arithmetic types in switch
statements?  It's really inefficient to do int comparisons when the actual
thing you're CASEing on is a byte.  I think that the type of the case labels
should be whatever the type of the switch expression; thus if I say "switch
(foo)" where foo is a char, all the case statements are cast to char.

On a similar note, it annoys me that enums can only be int-valued, when 99%
of the time they'll fit in a char.  On memory-tight code, this causes me to
use #defines instead of enums, so that I can use a byte instead of an int.
The same goes for bitfields.  I'd change the enum syntax to "enum type {...}",
where type is optional (and defaults to int), but can be any numeric type.
Similarly, I should be able to use any integer type in a bitfield definition.

Robert Lenoil
Apple Computer, Inc.