Grouse: What's the point of enum?

Tim W Smith ts at cup.portal.com
Fri Apr 19 22:41:59 AEST 1991


Wow!  Both Henry Spencer and Chris Torek missed the point of enumerated
types... next thing you know, getting involved in a land war in Asia
will be a good idea.

Anyway, the real point is to allow lower case names for constants.  If
you try this in a header file:

	#define opened 1
	#define closed 2

everyone will scream that you should have said

	#define OPENED 1
	#define CLOSED 2

whereas, if you instead go

	enum state { opened=1, closed };

people who read the code will be so busy trying to remember what the
heck and 'enum' is that they won't realize you've snuck in lower case
constant names.

						Tim Smith



More information about the Comp.lang.c mailing list