Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!amdcad!cae780!hplabs!hpcea!hpda!hpclla!mar From: mar@hpclla.UUCP Newsgroups: comp.lang.c Subject: Re: enum - enum ? Message-ID: <4400002@hpclla.HP.COM> Date: Mon, 8-Jun-87 19:47:48 EDT Article-I.D.: hpclla.4400002 Posted: Mon Jun 8 19:47:48 1987 Date-Received: Sat, 13-Jun-87 04:39:16 EDT References: <139@starfire.UUCP> Organization: Hewlett-Packard CLL Lines: 31 >I think it would be reasonable for enum - enum to be an integer value, >just as ptr - ptr is, and for similar reasons; you want the 'distance' >between them. This would also imply enum + int == enum and enum++ is ok The following statements assume the declaration: enum color {red=1, blue=4, green=5}; enum fruit {apple=1, orange=4, grape=5}; for clarification: color is an enum; red is an enum constant; What is the use of an expression such as red++ ?? Enum constants are integer constants - why would you want to allow the modification of a constant (ie: red++) - might as well use ints. I agree that enums in general should be implemented as a special case of integers - allowed wherever integer constants are allowed, but with extra restrictions regarding assignment of two different enums (color = fruit) and addition of enums or enum constants. Subtracting two enum constants or adding a integer to an enum constant could be useful, but what would you use the addition of two enum constants for? Should enum_constant - enum_constant only be allowed if both enum constants are elements of the same enum type? I would like to have enums and enum constants be flexible, but I also would like the extra type-checking for enums; otherwise I might as well use #define's for compile-time constants. type.