Path: utzoo!attcan!uunet!convex!killer!ames!mailrus!tut.cis.ohio-state.edu!husc6!linus!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: enums Message-ID: <5698@haddock.ISC.COM> Date: 1 Aug 88 17:46:05 GMT References: <1608@dataio.Data-IO.COM> <469@m3.mfci.UUCP> <1988Jul22.171612.6225@utzoo.uucp> <5447@ihlpf.ATT.COM> <11686@steinmetz.ge.com> <19795@cornell.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 16 In article <19795@cornell.UUCP> blandy@cs.cornell.edu (Jim Blandy) writes: >And how should we write our enum->int converter? A cast? [Not enough >information if we want to allow duplication of enum names] Actually, I'd rather have enum arithmetic behave somewhat like pointers, in that enum+int => enum and enum-enum => int. Then you can convert an enum to its ordinal via an expression like "ord = RED - ZEROCOLOR;". This still doesn't solve the problem of duplication of enum names, but that's related to the sticky issue of anonymous aggregate constants. Using my proposed "remote" operator, you would write "remote(enum color, RED)" if RED alone is ambiguous. (Personally, I don't think it's worth the effort, but if "remote" or equivalent is added for other reasons, then it could probably handle this problem as well.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint