How should 'enum's work?

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Oct 29 15:12:28 AEST 1984


> ... (although you should
> have to name 100 to ensure that the variable has enough range)

I like all Kevin's suggestions on enums before this one.  enum++
where there is no "next" value is no worse than pointer++.  Perhaps
pointer++ past the valid range should be outlawed (I have seen it
cause subtle bugs, including in the PDP-11 C compiler), but doing
this would outlaw a vast amount of existing code.

> If you want to get fancy, you could enforce that *only* the enum type
> used in the dimension of an array declaration may be used to subscript
> that particular array...

Eh?  What syntax for array declarations are we talking about here?

> The conversion of an enum to char * through a direct cast should yield
> a string giving the enum identifier.

This would require storing all the enum names in run-time data space.
It would also be a rule unlike any other in C.  I vote against this one.



More information about the Comp.lang.c mailing list