enums

Richard A. O'Keefe ok at quintus.uucp
Tue Aug 2 07:54:46 AEST 1988


In article <2404 at boulder.Colorado.EDU>
swarbric at tramp.Colorado.EDU (Frank Swarbrick) writes:
:Personally, I would like it to be even a little more like Pascal.
:Let's say I have
:	typedef enum {red, white, blue} flag_colors;
:I would like:
:	flag_colors flag;
:	flag = blue;
:	flag++;
:to have it so flag is now red.
:This is like Pascal's succ() and pred() operators.

No it isn't.  The Pascal fragment
	var: flag: (red, white, blue);
	...
	flag := blue;	
	flag := succ(blue);
is *illegal* and any half-way decent Pascal system will give you a
run-time error if you try it.  (It's just the same in Ada.)



More information about the Comp.lang.c mailing list