switch (expression)
Robert Lenoil
lenoil at Apple.COM
Sat Jul 16 08:32:12 AEST 1988
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.
More information about the Comp.std.c
mailing list