Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!guido From: guido@mcvax.uucp (Guido van Rossum) Newsgroups: net.lang.c Subject: Re: enum function bug? Message-ID: <7079@boring.mcvax.UUCP> Date: Mon, 22-Sep-86 17:56:29 EDT Article-I.D.: boring.7079 Posted: Mon Sep 22 17:56:29 1986 Date-Received: Tue, 23-Sep-86 03:56:39 EDT References: <299@sdchema.sdchem.UUCP> <86900054@haddock> <572@opus.nbires.UUCP> Reply-To: guido@boring.uucp (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 28 Summary: reply to structure equivalence remarks Apparently-To: rnews@mcvax In article <572@opus.nbires.UUCP> rcd@nbires.UUCP (Dick Dunn) writes: >[example with enum {a= 3+3, b, c} in one file and enum {a= 2*3, b, c} >in another] > >If you admit that name equivalence is inadequate (which I believe) but that >this example carries structural equivalence too far (which I also believe, >I think), then where do you draw the line? In my eyes, in the example you give the two types are clearly structurally equivalent. After all, the two expressions have to be constant expressions, which is a well-defined term (in C!). I propose the following rule for enum equivalence: Two enumerated types are equivalent if they have the same 'tag' (or no tags), and define the same set of enumeration constants with the same associated value for each constant. (This will find even enum {a=2, b=1, c=0} and enum {c, b, a} equivalent!) By the way, I agree with the proposed ANSI standard which defines that enums are equivalent to ints! This is the only suitable way to do it *in C*, even though for any other language, to be designed newly, enums should be distinct types. I also agree with Lint checking enum equivalence -- but there should be a way to turn it off, since I believe that lint should not issue any errors (warnings are ok) for strictly ANSI-conforming C programs. -- Guido van Rossum, CWI, Amsterdam