enums

Henry Spencer henry at utzoo.uucp
Sat Jul 30 06:33:06 AEST 1988


In article <5447 at ihlpf.ATT.COM> nevin1 at ihlpf.UUCP (00704a-Liber,N.J.) writes:
>In article <1988Jul22.171612.6225 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>>It does in fact include them, in the simplest and stupidest form possible.
>
>By saying that the dpANS C version of enums is 'the simplest and stupidest
>form possible', you have implied that there are much better forms of enums
>around.  Could you please enlighten us on to what these might be?

Well, I actually meant "stupidest" in the sense of "they didn't try to be
clever about it", rather than "I disapprove of what they came up with".
The fact is that enums have always occupied a vague never-never land between
being a fancy way to declare integer constants and being something akin to
Pascal's scalar types.  The latter opens up a number of thorny questions
like "can you use enums as array subscripts?".  X3J11 decided -- in my
opinion, wisely -- not to try to solve these problems.  They also decided
that enums were in sufficiently common use that deleting them entirely is
not practical.  So they opted to make them a way to declare integer constants
and (sort of) integer subtypes.  This sacrifices the error checking possible
with more Pascalish semantics, but gets clear, simple, consistent semantics
(definitely lacking for enums before) without adding unproven inventions to
the language.
-- 
MSDOS is not dead, it just     |     Henry Spencer at U of Toronto Zoology
smells that way.               | uunet!mnetor!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list