Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!ucbvax!decwrl!mejac!gryphon!sarima From: sarima@gryphon.CTS.COM (Stan Friesen) Newsgroups: comp.lang.c Subject: Re: enums Message-ID: <5076@gryphon.CTS.COM> Date: 31 Jul 88 19:50:47 GMT References: <1608@dataio.Data-IO.COM> <469@m3.mfci.UUCP> <1988Jul22.171612.6225@utzoo.uucp> <5447@ihlpf.ATT.COM> <11686@steinmetz.ge.com> Reply-To: sarima@gryphon.CTS.COM (Stan Friesen) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 33 In article <11686@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes: > >- enums should be a sequence of values in increasing order. The values > should start at zero and increase by one. This allows the ++ and -- > operators to be used in a meaningful way. Yes, at least if I can force deviation from this order if necessary, such as making an enum to deasl with hardware generated values. > >- enums should not be conceptually mixed with ints. An explicit operation > should be required to extract the ordinal value of an enum, and to set > an enum to a value. Well, ONLY if you also redefine the syntax of the switch and case statements to allow both ints and enums. If I cannot do a switch on an enum where the case's have the enum constants as values an enum is almost useless. (After all I doubt that "case (int)red" is legal even if I would be willing to write such garbage). This is IMPORTANT. At least the ANSI draft requirement that enums act like int's also gaurentees that switch/case usage is legal and intuitive. > >- it would be nice to have separate namespace for the various enum > types. The current implementation treats enum names as if they were > #defined values. This was a good idea for structs, and it's a good > idea here. It allows development of modules wothout having to have a > master control for enum names. Statements like x=red would specify the > "red" for the enum type of x. enum type conversion could require a > cast. Very nice, I agree with my whole being. -- Sarima Cardolandion sarima@gryphon.CTS.COM aka Stanley Friesen rutgers!marque!gryphon!sarima Sherman Oaks, CA