Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 7/1/83; site rlgvax.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!guy From: guy@rlgvax.UUCP Newsgroups: net.lang.c Subject: Re: enums Message-ID: <755@rlgvax.UUCP> Date: Tue, 5-Jul-83 01:55:34 EDT Article-I.D.: rlgvax.755 Posted: Tue Jul 5 01:55:34 1983 Date-Received: Wed, 6-Jul-83 16:01:36 EDT References: <754@rlgvax.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 32 The compiler you are referring to did not deliberately refuse to allow "switch" on an enum; it was a compiler bug which has since been fixed. The original VAX-11 PCC allowed "switch" on enums, and any port of the PCC to a new machine should preserve that characteristic; this one fell through the cracks. The fact that the names for the enums come out of a global pool is a more serious problem; it was also a problem with structure members until the language was changed for the System III compiler (which also comes with 4.?BSD). The same change is a little more complex for enums; with structure members, you can always disambiguate a member reference by looking at the type of the structure being looked at, as the member is either being used as "foo.memb" or "foop->memb" (and the compiler is somewhat insistent about NOT attaching a member name to anything other than a structure of the proper type or a pointer to such a structure). Enum member names, however, sit by themselves as plain constants, and the only available context is the other terms of the expression. You would have to insist on something like: enum color { red, white, blue }; enum moon { new, quarter, half, full, harvest, blue }; enum color hue; enum moon luna; if (luna == moon.blue) ... which is what somebody said in an earlier article was what ADA did. This would require a somewhat incompatible extension to the language, although one could elide the enum name if it was unambiguous ("white" would be "color.white" as there is no "moon.white"). Guy Harris {seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy