Article View: net.lang.c
Article #9366Re: enum function bug?
From: Guido van Rossum
Date: Mon, 22 Sep 1986 21:56
Date: Mon, 22 Sep 1986 21:56
29 lines
2037 bytes
2037 bytes
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 <guido@mcvax.uucp>
Technical Details
Message-ID:
<7079@boring.mcvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!guidoReferences:
<299@sdchema.sdchem.UUCP> <86900054@haddock> <572@opus.nbires.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!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