Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.UUCP Newsgroups: comp.lang.c Subject: Re: enum - enum ? Message-ID: <516@haddock.UUCP> Date: Fri, 5-Jun-87 19:29:30 EDT Article-I.D.: haddock.516 Posted: Fri Jun 5 19:29:30 1987 Date-Received: Sat, 6-Jun-87 09:58:06 EDT References: <139@starfire.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Organization: Interactive Systems, Boston Lines: 23 In article <139@starfire.UUCP> merlyn@starfire.UUCP (Brian Westley) writes: >What does the current standard say about enum - enum (both same enum type)? It says that enums are just ints. Personally, I think I'd be happy to have both enums and chars behave like pointers arithmetically (e.g. char+int == char, enum-enum == int, other combinations illegal), provided there's also a type "byte" ("short short"?) for arithmetic usage. >I know (int) green - (int) red will always work, but it's ugly. >If enums are too strongly typed (what is this, Pascal?) people will >go back to lists of #defines. But if enums are too weakly typed, what's their advantage over ints? I tend to use enums only when they would be legal in the strictest compilers, i.e. when the actual values are completely arbitrary. Given the suggested "pointer-like" semantics for arithmetic, and the ability to declare an array indexed by enums (or other types!), I could find more use for them. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint int hue[enum color] = { RED: 0x00F, GREEN: 0x0F0, BLUE: 0xF00 }; /* I wish */