ANSI standard and enums

Ken Arnold%UCB arnold at ucsfcgl.UUCP
Thu Oct 25 04:07:43 AEST 1984


> I would like to pose a question to the user community.
> What position should the ANSI committee take regarding enumerated types?
>   a. leave them out of the language
>   b. "tighten up" enums so they behave less like regular ints
>   c. leave them wishy-washy like they're implemented in many compilers
> 
> This is not a joke. The question to even have them in the language is
> valid. The only real use for enums that we could see was to provide
> symbolic names for constants so that symbolic debuggers could access them.
> Other than that, it appears that enums could be replaced with appropriate
> #defines.

I always thought that the most useful potential use for enum's was to
replace "appropriate" #define's.  Not only is it a regular pain to type
30 or 50 equivalents of

	# define	A	1
	# define	C	2
	. . . .

but adding new ones in order is a real pain.  For example, adding a
definition of "B" to the above list in alphabetical order requires
renumbering "C" and everything after must be renumbered if the
numerical ordering is to match to actual order (which makes sorting
easier).  With enums, just an insertion into the list will do the same
job.  The idea of having constant available to debuggers by name is
nice, too, but not as functional.

So I would add
	d. make enum constants be considered exactly like integer
	   constants.

Although you can get away with this kind of usage, lint complains like
hell about using enum constants for subscripts, etc.  I would agree
that the current implementation is half-assed and doesn't really solve
any problem.  I would argue that either enums should equal integers or
they should be deleted.

		Ken Arnold



More information about the Comp.lang.c mailing list