enums

smb at ulysses.UUCP smb at ulysses.UUCP
Thu Jul 7 01:26:15 AEST 1983


	From: mark at cbosgd.UUCP
	Newsgroups: net.lang.c
	Subject: Re: enums
	Message-ID: <108 at cbosgd.UUCP>
	Date: Tue, 5-Jul-83 23:08:08 EDT
	References: <754 at rlgvax.UUCP>, <755 at rlgvax.UUCP>

	The real reason people don't use enums in C much is that PCC is
	too restrictive with them.  The main problem is that you can't ++
	or -- them, making for loops iterating over them impossible.
	You also can't do < or > comparisons on enums.
	For example, if SIG* were made an enum, there would be no way
	to catch all signals.  If E* (errnos) were made enums, there
	would be no way to check errno for a legal value.  There is
	no way to have an array whose subscript is an enum, making it
	impossible to have an array of strings for perror, or an array
	of old values for signals.

Note that Pascal's enumerations suffer from none of these problems.
Enumerations in Pascal are by definition an ordered set, with the
operations 'pred' and 'succ' permitted (though you can't do 'pred' on
the first element, nor 'succ' on the last).



More information about the Comp.lang.c mailing list