🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5209

Re: switch (expression)

#5209
From: Karl Heuer
Date: Mon, 18 Jul 1988 16:24
16 lines
1276 bytes
In article <14036@apple.Apple.COM> lenoil@apple.apple.com.UUCP (Robert Lenoil) writes:
>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...

This is a Quality of Implementation issue.  A good optimizer will notice the
size of the switch parameter, and take appropriate action.

>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.

"Each enumerated type shall be compatible with an integer type; the choice of
type is implementation-defined" [Jan88 dpANS, 3.5.2.2].  I believe this allows
the implementation to use bytes for byte-sized enumerations.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID: <5255@haddock.ISC.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!rutgers!ucla-cs!sm.unisys.com!ism780c!haddock!karl
References: <1988Jul12.105547.13268@light.uucp> <14036@apple.Apple.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!rutgers!ucla-cs!sm.unisys.com!ism780c!haddock!karl
From: karl@haddock.ISC.COM (Karl Heuer)
Newsgroups: comp.std.c
Subject: Re: switch (expression)
Message-ID: <5255@haddock.ISC.COM>
Date: 18 Jul 88 16:24:04 GMT
References: <1988Jul12.105547.13268@light.uucp> <14036@apple.Apple.COM>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 16